PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Dec 19, 2014 4:21 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon May 19, 2008 2:45 pm 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com
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?


Top
 Profile  
 
PostPosted: Tue May 20, 2008 3:36 am 
Offline
Forum Commoner

Joined: Mon May 12, 2008 8:41 am
Posts: 82
Location: Ireland
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).


Top
 Profile  
 
PostPosted: Tue May 20, 2008 4:45 am 
Offline
DevNet Master
User avatar

Joined: Mon Sep 19, 2005 6:24 am
Posts: 3587
Location: London
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. :)


Top
 Profile  
 
PostPosted: Wed May 21, 2008 5:10 am 
Offline
DevNet Master
User avatar

Joined: Tue Nov 02, 2004 6:43 am
Posts: 2704
Location: Ireland
Why not the Star Trek Red Alert? ;) Add a visual cue also - setup a string of red flashing flourescents around the place!


Top
 Profile  
 
PostPosted: Thu May 22, 2008 9:26 pm 
Offline
DevNet Master
User avatar

Joined: Mon Oct 25, 2004 9:29 pm
Posts: 3698
Location: New Jersey, US
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group