Using unit tests as part of an 'install' procedure.

Discussion of testing theory and practice, including methodologies (such as TDD, BDD, DDD, Agile, XP) and software - anything to do with testing goes here. (Formerly "The Testing Side of Development")

Moderator: General Moderators

Using unit tests as part of an 'install' procedure.

Postby onion2k » Mon May 19, 2008 2:45 pm

Seems really obvious when I think about it, but has anyone here written an installer that runs a bunch of unit tests to make sure the thing installed properly? I'm writing a thumbnail generator part of which is a generic image class. One of the unit tests is:

Syntax: [ Download ] [ Hide ]
       public function testImageFormats() {
 
            $image = new image();
            $this->assertEqual($image->gd_support_gif, true);
            $this->assertEqual($image->gd_support_png, true);
            $this->assertEqual($image->gd_support_jpg, true);
 
        }

When $image is created it gathers some data on what image functionality is available and sets the gd_support values ... if GIF creation isn't supported by the user's version of GD $image->gd_support_gif is false. While that's a useful unit test to check if my image class is working properly exactly the same check would also be a very useful during an installation process.

Has anyone considered taking Simpletest (or another unit test suite) and making an install script out of it?
User avatar
onion2k
Jedi Mod
 
Posts: 5263
Joined: Tue Dec 21, 2004 6:03 pm
Location: usrlab.com

Re: Using unit tests as part of an 'install' procedure.

Postby Bruno De Barros » Tue May 20, 2008 3:36 am

That would be intelligent, especially to check if all the functions in your script are running properly on that server (different servers might not support some stuff).
Bruno De Barros
Forum Commoner
 
Posts: 82
Joined: Mon May 12, 2008 8:41 am
Location: Ireland

Re: Using unit tests as part of an 'install' procedure.

Postby Jenk » Tue May 20, 2008 4:45 am

Not quite, but I have an installer that runs the tests (subtle difference from how your post reads)

Our staging servers automatically update every hour with the latest versions from our repository (including tests) and runs the tests/specs immediately. We also use a loud comical family fortunes "eh-ah" when a test fails to alert us. :)
User avatar
Jenk
DevNet Master
 
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: Using unit tests as part of an 'install' procedure.

Postby Maugrim_The_Reaper » Wed May 21, 2008 5:10 am

Why not the Star Trek Red Alert? ;) Add a visual cue also - setup a string of red flashing flourescents around the place!
Pádraic Brady

http://blog.astrumfutura.com
http://www.survivethedeepend.com
Zend Framework Community Review Team
Zend Framework PHP-FIG Representative
User avatar
Maugrim_The_Reaper
DevNet Master
 
Posts: 2704
Joined: Tue Nov 02, 2004 6:43 am
Location: Ireland

Re: Using unit tests as part of an 'install' procedure.

Postby Ambush Commander » Thu May 22, 2008 9:26 pm

There's a few crucial differences, I think:

1. SimpleTest (and most other unit testing suites, I think) don't let you escalate errors. When you're installing an application, some errors will be fatal, others will merely be warnings (the user can still use the application, but some functionality will be degradeD).

2. Any unit testing framework means substantial bootstrap code that needs to be shipped with the application. Most people don't distribute a unit testing library with their code; with this sort of setup, you have to. An addendum to this is that most install scripts attempt to run with as few dependencies as possible: you don't want to have to run an install script to run the install script!

3. There's really no need to make an install script out of SimpleTest! Just make it really easy for users to run the unit tests after installation. The SimpleTest suite doesn't even need to know about the installer; it's an I (the installer) will call you (test suite).

I agree it's important for tests to be run, especially before shipping code, and it's important for tests to be run on a variety of platforms by many users. But I don't think most users will be interested in doing something like that.
User avatar
Ambush Commander
DevNet Master
 
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US


Return to Testing

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests