Friday, July 05, 2013

The importance of automating test cases

To maintain legacy code for a longer period of time, it is best to write automated Unit testing,

     This will maintains product quality from the situation where the fresher/ new developer has added code without understanding.
 
     In my work environment,  Once the code is committed to repository, Hudson server triggers the build, test for automated Unit testing cases. If all the Unit testing cases are passed, then only it will allow us to submit.

    One new guy has modified some code, it is affecting some functionality. This error was captured while running the automated test cases.

In Android to automate test cases, InstrumentationTest Runner is available.

Example for writing UnitTesting[UT]:

In case of UT, we can mock objects instead of testing with real object. I encountered the problem in getting an IP address when wifi and wifi direct is on.

   So To solve this problem, I mocked the wifi, wifi direct scenario in UT cases, so that it wont never happen again and if some one is modifying the source code, his source code should pass my testcase,Then only he can submit the source code to repository.