Simple Test or phpUnit

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

alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Simple Test or phpUnit

Post by alex.barylski »

Which is better and why???

What does Zend use?
Last edited by alex.barylski on Mon Sep 04, 2006 3:47 pm, edited 1 time in total.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Edit: I've found there are indeed 2 versions of phpUnit the one on SF is the newbie??? I prefer the other as it has a O'Reilley cookbook ;)

Ok, I've searched for both and have concluded there are at least seperate concurrent versions for phpUnit

One by a fellow named Sebastien(sp?) and the other which pops up as SF when Googled???

I like the Former as it's in version 3.0 but I cannot seem to find the URL to download or instructions, etc???

The SF version only appears to be in BETA???

WTF???
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

I use SimpleTest because it has more Mock Objects experience, it has a WebTestCase, it is geared towards ease of use out of the box (i.e. having both HTML and CLI based reporters), and I trust Marcus Baker's development decisions (no offence towards Sebastian Bergmann intended)
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Ok...noticed you in the documentation for SimpleTest ;)

Which one does Zend framework use? Seeing how I'm using ZF I might as well stick with convention...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'll agree with Jason and add: plus Marcus actually posts here!
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

Hockey wrote:Ok...noticed you in the documentation for SimpleTest ;)
Yep, I like to jump in on the easy parts of projects ;)
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

Hockey wrote: Which one does Zend framework use? Seeing how I'm using ZF I might as well stick with convention...
http://www.phpunit.de/

Make sure you are installing PHPUnit2 though.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Ok fine...two against one...I'm convinced I'll use SimpleTest :P

However you both promise me it's just as complete if not more complete than phpUnit???

And when I have questions you help me :P Just kidding on that last one of course


Cheers :)
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

SimpleTest is great except when you want to modify the reporting behaviour. But then PHPUnit doesn't have an HTML Reporter at all so there is a clear winner there.

Marcus is a really nice guy so I'm actually a little guilty I even tried PHPUnit now :(

I'm really looking forward to the PHP 5 version of SimpleTest because the current version doens't cut it with heavy OOP code atm without albeit minor tweakage.

This is essential:

Code: Select all

class BlahWhatever extends UnitTestCase {
    // get the value of a private or protected property, properly and politey
    static function expose($obj, $prop)
    {
        $reflection = new ReflectionClass($obj);
        $prop = $reflection->getProperty($prop);
        return $prop->getValue($obj);
    }
}
sike
Forum Commoner
Posts: 84
Joined: Wed Aug 02, 2006 8:33 am

Post by sike »

ole wrote:SimpleTest is great except when you want to modify the reporting behaviour. But then PHPUnit doesn't have an HTML Reporter at all so there is a clear winner there.

Marcus is a really nice guy so I'm actually a little guilty I even tried PHPUnit now :(

I'm really looking forward to the PHP 5 version of SimpleTest because the current version doens't cut it with heavy OOP code atm without albeit minor tweakage.

This is essential:

Code: Select all

class BlahWhatever extends UnitTestCase {
    // get the value of a private or protected property, properly and politey
    static function expose($obj, $prop)
    {
        $reflection = new ReflectionClass($obj);
        $prop = $reflection->getProperty($prop);
        return $prop->getValue($obj);
    }
}
care to explain why you think exposing protected and private members is essential? in my book you should test the behaviour rather than explicit variables.

cheers
Chris
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

I find testing the internals is shorthand for an otherwise very long test of the behaviour.

Oh and that is probably a bad name for the function because it doesn't actually expose the varible just gets its value at one specific moment in time.
sike
Forum Commoner
Posts: 84
Joined: Wed Aug 02, 2006 8:33 am

Post by sike »

i see what you mean - but i think the test knows much too much on the internals of the testee. that could lead to brittle tests imho.

cheers
Chris
User avatar
Ollie Saunders
DevNet Master
Posts: 3179
Joined: Tue May 24, 2005 6:01 pm
Location: UK

Post by Ollie Saunders »

Yes you could be right.
I'm out of my depth here really.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

I use SimpleTest. Easy to setup, quick, better support for Mocks and Web Testing, author posts here, PHPUnit stays too close to JUnit (not the best approach for PHP).

PHPUnit Beta is picking up the pace, but testing really only needs the basics and SimpleTest has them all. A fully PHP5 compliant version would be killer. Drop a line if you need help ;).
User avatar
dbevfat
Forum Contributor
Posts: 126
Joined: Tue Jun 28, 2005 2:47 pm
Location: Ljubljana, Slovenia

Post by dbevfat »

I use SimpleTest, but have recently decided to take a better look at PHPUnit2, since it has quite a few nice features that ST doesn't, say code coverage for example.

IMO if you're new to testing, then both are "better". ;)
Post Reply