Jump to content

test driven development vs. unit testing


skaterdav85

Recommended Posts

I was reading an article on test-driven development in PHP, and I was wondering what the difference is between that and unit testing. Is unit testing something that you do after you create the test? Here is the article if you're interested:http://net.tutsplus.com/tutorials/php/the-...en-development/

Link to comment
Share on other sites

Unit testing is a specific component of the overall testing process - in which you check each atomic part of the program individually. For example, you may have a test suite that passes input to each function in the program, and checks to see whether the output is correct, one by one. Unit testing is important in all development ideologies (or else you don't know whether your program works :)).Test-driven development does rely on unit testing to work, however, it is a broader ideology that, as the article states, involves specifying the program as a series of tests, then just writing code until you don't fail those tests. As the article says, it forces you to have your test suite ready before you start writing, and to constantly use it, instead of writing your code without any idea whether it all works (in a formal sense, not just "doesn't crash") or not. However, your tests should probably include more than just unit tests.

Link to comment
Share on other sites

"Test Driven Development" is simply a way to think about, and use, Unit testing and similar things.Normally, you write code, and test it. Test driven development is an ideology where you do things the other way around - you write the tests first, in the way the user is supposed to use it, and specify the expected outputs or errors in each case. Only then, you write code that eventually passes these tests. The ideology also includes wiriting new tests for each bug you later find in your application.Unit testing is great for libraries, and as far as PHP code is concerned, you only need PHPUnit to make it work. That, and sample data of course... There's this Selenium service which makes PHP and JavaScript unit tests run on several platforms too, further simplifying testing, but that's just another "extra".To test UI elements though, such as ensuring that a button of your app is always visible, requires more than unit testing... it requires either manual testing, or a macro test - a macro bot written specifically to do things that a user would otherwise do manually.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...