Here is the detail for how to setup code coverage using jacoco plugin which is OOB come out with SONAR :
- Write sample java project called ant-jacoco-codecoverage
- Project folder structure would be given as below snapshot:
- Under the target folder you may have to create classes & reports folders where reports folder will have one more folder called junit
- Write sample Java class One.java in src folder you can copy paste below code :
- public class One {
String message = "foo";
public String foo() {
return message;
}
public void uncoveredMethod() {
System.out.println(foo());
}
}