0

I wanted to get code coverage of regression tests,which tests java webserver endpoints.

Things I have
1. I am having jar file of source
2. Regression code written using TestNG framework.

So here, I will run this jar file to run webserver and then I will run my regression code which will test running webserver.Here I wanted to get code coverage report of Regression tests.Can anyone give any suggestion ?

Akash Shinde
  • 925
  • 3
  • 14
  • 31

2 Answers2

0

You can use EMMA(A free code coverage tool). If you are using eclipse you can directly get it from market place. Also it supports running individual Java class file or jar file. Here is the link for more information.

http://emma.sourceforge.net/intro.html

Harini
  • 105
  • 3
  • 13
0

If you're using Maven, you can have a look at qualinsight-maven-cobertura-mojo. There is a companion Github project that provides examples showing how to use it along with jetty (versions 7.6.x, 8.1.x, 9.2.x, 9.3.x). In the exmaples JUnit is being used, but it has no impact at all on the result, you can use TestNG if you want to.

The example shows how to use this Maven plugin and configure your project in order to:

  1. Instrument your code for coverage with qualinsight-maven-mojo-core
  2. run your Jetty server and deploy instrumented code
  3. run your tests (you'll have to replace Junit tests by TestNG ones, and make sure they are run during the integration-test phase)
  4. stop your Jetty server (this will dump coverage file to disk)
  5. Generate coverage report

If needed coverage reports can then be imported in SonarQube using the Generic Coverage plugin (see documentation.)

Note that this plugin has some advantages and limitations compared to cobertura-maven-plugin (see its documentation), but given the description of your requirements, none of the limitations seems to be a blocker in your context.

Kraal
  • 2,779
  • 1
  • 19
  • 36