Tuesday, August 5, 2008

JUnit testing tips

As we used to write our JUnit test cases for all Story cards we develop, well we follow TDD (Test Driven Development). Here are the rules we follow for our JUnit testcase as part of our TDD...
  • Never break others test case.
  • Don't update any database values as part of your JUnit testing. (But we can read DB values if required.)
  • Test your business logic no need to test java or other API's as they are well tested.
  • Try to avoid Mock Objects usage. (I think some times this mock objects will cause problems when you debug your test case - I am not quite sure to give any instance but I think so)
  • And he used to tell one more thing Clean first before committing something back to repository.
  • Ensure your JUnit test is passing on cruise control. Some time JUnit will pass locally when it actually running along with Cruise Control test beds it fails so need to ensure till you get positive build results other wise need to fix again.