Functional Coverage with Jacoco Agent in Maven project(uses Apache Spark)

Hello Friends ,
In last day i was doing some configuration work to extract functional coverage report using JACOCO Agent.jar. At first i would mention that i was working on maven project and it was running over the Apache Spark 1.5 .
I followed steps mentioned below to get functional coverage  (You can comment below if you have any better way to do this 🙂 ).

1. Download jacoco-agent.jar

2. Extract the jar and you’ll find a jacoco-agent.jar inside the extracted folder.

3.Configure spark-default.conf with your project(as most probably you had configured in start of your project) and jacoco-agent.



4. Run the spark-submit command.

5. Execute your functionality(or Querry).

6. Now stop the spark-submit command.

7. jacoco.exec would be placed at the destfile path(/tmp/jacoco).If already yo have generated your jacoco.exec from any other way you can follow step 8 & 9 to generate report in HTML format.

8. Add following plugin to pom.xml in your project :

<!– Jococo–>
      <!– Sets the path to the file which contains the execution data. –>
      <!– Sets the output directory for the code coverage report. –>
  <!– Sets the VM argument line used when unit tests are run. –>
  <!– Skips unit tests if the value of skip.unit.tests property is true –>
  <!– Excludes integration tests when unit tests are run. –>
<!– Jococo–>

  1. Run mvn test from from your project.Coverage report in html format generated at specified location as given in maven plugin.



About Rahul Kumar

Software Consultant At Knoldus
This entry was posted in Scala. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s