Unit Testing libraries in PHP
Moderator: General Moderators
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
Unit Testing libraries in PHP
Since its about a tool and not a question on writing them I put it here...
I've spent the last few months tinkering with SimpleTest, and recently thought about looking at PHPUnit2 - what I'm not clear on is where they differ, and which one people prefer. PHPUnit2 (outwardly at least) seems to see a lot more development, and the 3.0.0 alpha looks like its adding some new features. (and well, PHPUnit looks kind of nicer what with the wealth of documentation, the flashy output, and such).
Is there a significant difference between the two? Which do you prefer using? Do both integrate well into Eclipse (IDE)?
I've spent the last few months tinkering with SimpleTest, and recently thought about looking at PHPUnit2 - what I'm not clear on is where they differ, and which one people prefer. PHPUnit2 (outwardly at least) seems to see a lot more development, and the 3.0.0 alpha looks like its adding some new features. (and well, PHPUnit looks kind of nicer what with the wealth of documentation, the flashy output, and such).
Is there a significant difference between the two? Which do you prefer using? Do both integrate well into Eclipse (IDE)?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
I'm still not sold on Pear being used for everything, so I go with SimpleTest. Not that they are all that different, but since the author actually posts here, it gets more weight. Beyond that, it was the most straight forward. Granted, it took me awhile to actually sit down and force myself to figure it out. Marcus' tutorials and documentation helped a lot once I had the patience to read it.
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
I still need to jump on this bandwagon 
Most likely I'll go with simpletest because it look like a few people around here can help me out with that one - but someone mentioned the examples in the docs don't even pss the tests with PHP5, is that right?
Can I unit test something once it's already been written or is that completely besides the point? Most people seem to write test, and then write code the pass the test.
Most likely I'll go with simpletest because it look like a few people around here can help me out with that one - but someone mentioned the examples in the docs don't even pss the tests with PHP5, is that right?
Can I unit test something once it's already been written or is that completely besides the point? Most people seem to write test, and then write code the pass the test.
- Maugrim_The_Reaper
- DevNet Master
- Posts: 2704
- Joined: Tue Nov 02, 2004 5:43 am
- Location: Ireland
That was meMost likely I'll go with simpletest because it look like a few people around here can help me out with that one - but someone mentioned the examples in the docs don't even pss the tests with PHP5, is that right?
Yes, you can. Though I would suggest writing the tests first-off without referencing the class too much (even if the class exists it might offer a few new insights). Then amend them, or the class to pass them. It's also a good idea to write tests before making any changes to an existing class - so you can change, test, change, test, in a way that let's you catch bugs fast. One thing I found hard originally is that in writing tests you may find some classes need some additional methods to even allow testing. For example, it you read my thread on ServiceLocator/Singleton/Registry (last 2 days) I needed a hasService/hasSearchLocation methods so my tests could check if such existed (basic getters for a private property). This extra bits and pieces are used solely for testing. I've seen a few people mention classes should also be written to facilitate easier testing...so that falls under this heading.Can I unit test something once it's already been written or is that completely besides the point? Most people seem to write test, and then write code the pass the test.
PHPUnit has received 0 votes so far...hmmm. Another factor I though of - PHPUnit requires PEAR I think, but SimpleTest can be bundled with a distributed application easily.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Well then, if I'm gonna jump on the bandwagon it might as well be for something useful and practical. I'll try to include some tests with the next release of swiftMaugrim_The_Reaper wrote:Yes, you can. Though I would suggest writing the tests first-off without referencing the class too much (even if the class exists it might offer a few new insights).Can I unit test something once it's already been written or is that completely besides the point? Most people seem to write test, and then write code the pass the test.
/goes off to get simpletest
You might also have to look into one of Marcus's other projects fakemail to help out in your testing.d11wtq wrote: Well then, if I'm gonna jump on the bandwagon it might as well be for something useful and practical. I'll try to include some tests with the next release of swift
/goes off to get simpletest