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:
- Instrument your code for coverage with
qualinsight-maven-mojo-core
- run your Jetty server and deploy instrumented code
- run your tests (you'll have to replace Junit tests by TestNG ones, and make sure they are run during the
integration-test
phase)
- stop your Jetty server (this will dump coverage file to disk)
- 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.