10/01/2008

Testing with Emma + JUnit

In the previous entry I fixed various errors to pass Checkstyle, FindBugs, JUnit, and PMD, so that I got verified. However, if I take a look at the report of Emma, it says the coverage is still 82% for method, 72% for block, and 80% for line. This time, I will try to fix even more so that its line coverage is going to be 100%.

Adding Test Cases

On the report, red background specifies I haven't tested that part. It was shown that I didn't test methods such as toString, getTop, and etc. To fix it, I wroite a test case for those using methods such as "assertEquals()" or "testIllegalTop()".

While I was writing test cases, I also checked javadoc of JUnit and it helped me understand what the method is doing. There are a lot of methods that look useful, so in the future I will try those to test my code in various ways. On my PC, javadoc was located in the following address.

file:///C:/000/eclipse/tools/junit4.5/javadoc/index.html

Conclusion

Emma is a useful tool that let us know where we didn't test and allows us to fix it. By doing it we are able to improve the quality of the system and make it more reliable.

The fixed code can be downloaded from here.

No comments: