Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Background

Sonar currently reports on the code coverage of unit tests only using the Emma code coverage tool. It is however

desirable to have code coverage for integration and acceptance tests as well. This will help us measure our progress

towards automating all manual tests and improve the efficiency of our test base. 

Jacoco

Jacoco is a code coverage tool that uses a different approach from Emma in to obtain code coverage data. Basically, 

it does bytecode instrumentation on-the-fly using the java agent technology. It works by inserting probes (additional instructions

that record the fact that they have been executed) into the code base accessible to the virtual machine. It is therefore important

to define inclusions and exclusions to restrict jacoco to mifos code.

Getting the tools

Download jacoco 

Download sonar jacoco plugin 

Download sonar 

Insert the jacoco plugin in the $SONAR_HOME/extensions/plugin  directory

Doing the business (getting coverage report - integration tests)

  • Modify the pom.xml in $MIFOS_HOME/applicaton directory by adding the following line to maven-surefire-plugin configuration element
    • <argLine>-javaagent:$
      Unknown macro: {jacoco.agent.path}
      =destfile=$
      Unknown macro: {jacoco.file.path}
      ,includes=org.mifos.,excludes=javaassist*</argLine>
  • Run acceptance tests, supply the arguments defined in the maven-surefire-plugin above
    • mvn -Djacoco.agent.path="/path/to/jacoco/library/jacocoagent.jar" -Djacoco.file.path="/path/to/coverage/dump/jacoco.exec" clean install
  • Run sonar analysis on entire project

mvn -Dsonar.jacoco.itReportPath="/home/kojo/jack.exec" sonar:sonar -Dsonar.dynamicAnalysis

consider using -Dsonar.dynamicAnalysis=reuseReports  to considerably reduce the time taken for code analysis

  • Go to sonar web interface and click on 'configure widgets' to add IT coverage widget 

Miscellaneous 

Jacoco Ant tasks

References

- Java agent

- Jacoco

  • No labels