Skip to main content

Posts

Showing posts from March, 2017

Integrating the JaCoCo code coverage plugin into a Java Maven project for unit testing with testng

I’ll show how to do this for both offline instrumentation and for using the JaCoCo runtime agent. It is very easy because you don’t need to change the usual way of writing your tests. Its only a matter of changing the pom.xml file in your maven project. 1. JaCoCo code coverage with JaCoCo runtime agent Since we use testng for unit test writing, we put the following dependency under dependencies. < dependencies > < dependency > < groupId > org.testng </ groupId > < artifactId > testng </ artifactId > < version > ${testng.version} </ version > < scope > test </ scope > </ dependency > </ dependencies > Then under build, we first need to have the JaCoCo plugin put under the plugins section of your project pom.xml. (Note - this is the parent pom we are referring to) This plugin configuration...