Bay Area Startups and Technologies Marina's Web Scale Coral Reef

Tuesday Jun 23, 2009

At this month's LAMP meetup we had an educational talk on Unit Testing by Jakob Heuser, a web engineer from LinkedIn. In PHP, there are a number of frameworks used by developers including SnapTest, PHPUnit, SimpleTest, and Tesrilence. The main principle behind Unit Testing is to validate application requirements.  This includes checking application logic that implements a give requirements, making sure the fault flows are managed accordingly, and various conditional boundaries are satisfied. Unit testing focuses on testing smallest component of the program, such as function, public method, or an include file. With SnapTest, it is pretty straight forward to get started. After implementing PHP classes to test the application you can start multiple tests simultaneously to expedite the testing process. While SnapTest has a low starting barrier, testing frameworks like PHPUnit is a much more comprehensive framework. But regardless of the framework that you pick, here is an ideal order in which you should be building and testing your application:
  1. design your class/API
  2. create a test suite
  3. implement the class/API
  4. run the test suite
  5. fix failures or errors and go to #4 again
After all test suites were ran and errors have been fixed, it's a good time to do refactoring and simplify the application logic, create a more elegant implementation, and then obviously run the tests again to make sure that newly introduced logic doesn't break anything else in the program.

Jakob maintains and contributes towards SnapTest framework and his presentation is available at:
http://www.slideshare.net/Jakobo/unit-testing-first-steps
Comments:

Post a Comment:
  • HTML Syntax: NOT allowed