Re: Help me understand unit testing?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 21, 2009 at 7:01 PM, Murray <planetthoughtful@xxxxxxxxx> wrote:
> Hi All,
>
> I'd like to understand unit testing better (or, in fact, at all). I
> understand the broad idea that testing Is A Very Good Thing, but when I have
> tried to look into it further (for example, have just been looking through
> the PHPUnit site), I always end up thinking 'This looks like more trouble
> than it's worth.' I'm sure that's down to me and not the process of unit
> testing, but I'd like to get some idea of how people on the list actually
> use unit testing in the real world.
>
> I'm assuming that you have your actual application classes and functions
> designed in their own files, and then you build a series of unit testing
> classes / functions in their own sort of space, but do you build these in
> parallel to your application code, or during alpha / beta testing etc?
>
> Any practical or even theoretical advice welcome!
>
> Many thanks,
>
> M is for Murray
>

Well this was a hard topic for me to grasp too.  A lot of times I
still get lazy about it, but I strive to do my best.  Unit testing
makes sure your code works as expected.  So if you're messing around
with stuff, keep re-running your test suite and see if your changes
break any of your tests.  This way you know whether or not your
changes are breaking the very apps that rely on your code.

Unit testing also allows you to quickly assess problems with different
servers, php upgrades, whatever.

Of course these are just little points.  Just give it a try and keep
going at it.  Once I started I noticed that I had been writing my code
all wrong.  Lots of weird dependencies, reliance on hard to recreate
state, stuff like that.  It helped me to start writing leaner methods
that targeted what they were supposed to do a lot better.

There's a lot of info on this subject all across the net & in books.
It isn't just limited to php, but programming in general.

V is for Vendetta?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux