Code Coverage

When writing unit test cases with TestNG the following questions will come.

1. Duplicating test cases

Manually we need to verify or we can use other metrics tools to see method usage to find what methods are used highly.

2. How many unit test cases are sufficient to cover all the code?

Use http://www.eclemma.org/ to see the code in color. Very nice tool

3. How to assure number of test cases?

We need t make sure that we are covering all types of error codes as part of testing.

Finally group them and run to see the overall performance and code coverage.

————————————————————————————————–

Group test cases in TestNG and run Emma coverage for given group. After that merge the sessions to get total code coverage by all the test cases.

http://www.eclemma.org/userdoc/coverageview.html Check Merge Sessions

————————————————————————————————–

After some time started getting following error.

java.lang.ClassNotFoundException: com.vladium.emma.rt.RT

Copy emma.jar from eclipse to project lib folder and add to classpath. Issue resolved.

http://jetbrains.net/tracker/issue/TW-1305

————————————————————————————————–

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s