Unit testing?
Moderator: General Moderators
Unit testing?
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
Thanks in advance,
Dom
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Unit testing?
http://www.google.com/search?q=unit+testing
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!
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!
Last edited by Jonah Bron on Wed Feb 09, 2011 4:57 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Unit testing?
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.
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.
- Jonah Bron
- DevNet Master
- Posts: 2764
- Joined: Thu Mar 15, 2007 6:28 pm
- Location: Redding, California
Re: Unit testing?
Ah, I didn't know that.John Cartwright wrote:I wouldn't recommend using Simpletest, since it's no longer under active development.
Re: Unit testing?
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?
@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?
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.
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.
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: Unit testing?
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.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.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: Unit testing?
Unit testing is the only way to go
Re: Unit testing?
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.
For testing your Javascript stuff I'd recommend QUnit.