Page 1 of 1

Unit testing?

Posted: Tue Feb 08, 2011 8:41 pm
by Domsore
I saw a lecture about extreme programming in the tutorials section and whilst I understood it, he mentioned something about Unit Testing and i've also seen the term thrown about quite a bit on the forum, could someone explain the term? Or reference to some reading material?

Thanks in advance,

Dom

Re: Unit testing?

Posted: Tue Feb 08, 2011 10:13 pm
by Jonah Bron
http://www.google.com/search?q=unit+testing :google:

Unit testing is a very powerful tool that allows one to keep track of the "functioning" state and the expected behavior of code automatically, along with other things. The mainstream implementation is PHPUnit.

Hit it, Josh! :teach:

Re: Unit testing?

Posted: Wed Feb 09, 2011 4:41 pm
by John Cartwright
I wouldn't recommend using Simpletest, since it's no longer under active development.

But seriously, it will revolutionize the way you program. By defining expected results by coding your tests first, then writing your code to pass the tests, you will find you will create much better code. It also is godsend when refactoring, because you can run all your tests to see if anything is broken, whereas otherwise bugs could easily go unnoticed.

Re: Unit testing?

Posted: Wed Feb 09, 2011 4:58 pm
by Jonah Bron
John Cartwright wrote:I wouldn't recommend using Simpletest, since it's no longer under active development.
Ah, I didn't know that.

Re: Unit testing?

Posted: Wed Feb 09, 2011 6:07 pm
by Domsore
At first glance, it looks a little confusing, however, im sure i'll get my head around it.

@John I use netbeans and I remember you saying you had and issue with PHPUnit and netbeans together? Is this something I should look out for?

Re: Unit testing?

Posted: Wed Feb 09, 2011 7:00 pm
by josh
Most developers use it as a development methodology, called test driven development. Rather than worrying about how to get a job done, you first are forced to focus on defining what the job is. It's akin to writing your user guide before the program.

For example in the software produce I sell there are literally millions of possible ways it could be configured by the user. In order to make sure I don't accidentally remove or alter previously built functionality in such a complex program, I use unit tests to "pin down" the way my software currently works.

A unit test differs from testing through your browser. It's like you take a small piece of code and run it on "life support" outside of the rest of the program, its some Frankenstein stuff. If your code is unit tested it can be run outside of it's original program. This promotes re-use across projects.

Re: Unit testing?

Posted: Mon Feb 28, 2011 12:04 pm
by social_experiment
josh wrote:A unit test differs from testing through your browser. It's like you take a small piece of code and run it on "life support" outside of the rest of the program, its some Frankenstein stuff. If your code is unit tested it can be run outside of it's original program. This promotes re-use across projects.
Now i understand what unit testing is about (kindoff). I was about to ask how it differs from normal 'browser testing' but this answered it for me.

Re: Unit testing?

Posted: Thu Mar 03, 2011 3:05 pm
by alvinphp
Unit testing is the only way to go

Re: Unit testing?

Posted: Tue Mar 22, 2011 5:40 am
by onion2k
I still use SimpleTest. It might not be under development any more but it does everything you need (for now) and it does it well.

For testing your Javascript stuff I'd recommend QUnit.