title: Jacoco Test coverage report shows 0%
body: <p>I have to get the code coverage of a application while business test are executed from a different code base.</p>
  
  <p>I use: Maven as my build
  Jbehave as my testing framework.
  The test are written in java.</p>
  
  <p>My application is a set of war files deployed on tomcat.</p>
  
  <p>The application code base is separate from test code base.</p>
  
  <p>In getting the coverage I followed the below steps.</p>
  
  <p><a href="http://i.stack.imgur.com/7rowG.png" rel="nofollow">1</a> Compile the test code using maven.</p>
  
  <p><a href="http://i.stack.imgur.com/FdvJU.png" rel="nofollow">2</a> Copy application classes from the place it was build (${app.code.dir}/target/classes) to ${test.code.dir}/target/classes </p>
  
  <p>[3] Run the tests and jacoco report through maven</p>
  
  <p>The mvn build: I have kept </p>
  
  <pre><code>&lt;profile&gt;
          &lt;id&gt;coverage&lt;/id&gt;
          &lt;activation&gt;
              &lt;activeByDefault&gt;false&lt;/activeByDefault&gt;
          &lt;/activation&gt;
          &lt;build&gt;
              &lt;plugins&gt;
                  &lt;plugin&gt;
                      &lt;groupId&gt;org.jacoco&lt;/groupId&gt;
                      &lt;artifactId&gt;jacoco-maven-plugin&lt;/artifactId&gt;
                      &lt;version&gt;0.6.3.201306030806&lt;/version&gt;
                      &lt;executions&gt;
                          &lt;execution&gt;
                              &lt;id&gt;default-prepare-agent&lt;/id&gt;
                              &lt;phase&gt;process-resources&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;prepare-agent&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;skip&gt;false&lt;/skip&gt;
                                  &lt;destFile&gt;${basedir}/target/jacoco-coverage.exec&lt;/destFile&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                          &lt;execution&gt;
                              &lt;id&gt;default-report&lt;/id&gt;
                              &lt;phase&gt;post-integration-test&lt;/phase&gt;
                              &lt;goals&gt;
                                  &lt;goal&gt;report&lt;/goal&gt;
                              &lt;/goals&gt;
                              &lt;configuration&gt;
                                  &lt;!-- &lt;skip&gt;true&lt;/skip&gt; --&gt;
                                  &lt;excludes&gt;
                                      &lt;exclude&gt;com/mytest/bdt/**&lt;/exclude&gt;&lt;!-- test classes --&gt;
                                      &lt;exclude&gt;com/mytest/bdd/**&lt;/exclude&gt;&lt;!-- test classes --&gt;
                                  &lt;/excludes&gt;
  
                                  &lt;dataFile&gt;${basedir}/target/jacoco-coverage.exec&lt;/dataFile&gt;
                              &lt;/configuration&gt;
                          &lt;/execution&gt;
                      &lt;/executions&gt;
                  &lt;/plugin&gt;
              &lt;/plugins&gt;
          &lt;/build&gt;
      &lt;/profile&gt;
  </code></pre>
  
  <p>The jbehave test are executed using :</p>
  
  <pre><code>    &lt;plugin&gt;
           &lt;groupId&gt;org.jbehave&lt;/groupId&gt;
           &lt;artifactId&gt;jbehave-maven-plugin&lt;/artifactId&gt;
          &lt;version&gt;${jbehave.core.version}&lt;/version&gt;
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;log4j&lt;/groupId&gt;
                      &lt;artifactId&gt;log4j&lt;/artifactId&gt;
                      &lt;version&gt;1.2.16&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
              &lt;executions&gt;
                  &lt;execution&gt;
                      &lt;id&gt;unpack-view-resources&lt;/id&gt;
                      &lt;phase&gt;process-resources&lt;/phase&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;unpack-view-resources&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
                  &lt;execution&gt;
                      &lt;id&gt;embeddable-stories&lt;/id&gt;
                      &lt;phase&gt;test&lt;/phase&gt;
                      &lt;configuration&gt;
                          &lt;includes&gt;
                              &lt;include&gt;${embeddables5}&lt;/include&gt;&lt;!--  TestSuite.java --&gt;
                          &lt;/includes&gt;
                          &lt;excludes /&gt;
                          &lt;ignoreFailureInStories&gt;true&lt;/ignoreFailureInStories&gt;
                          &lt;ignoreFailureInView&gt;true&lt;/ignoreFailureInView&gt;
                          &lt;threads&gt;1&lt;/threads&gt;
                          &lt;metaFilters&gt;
                              &lt;metaFilter&gt;${meta.filter}&lt;/metaFilter&gt;
                              &lt;metaFilter&gt;-skip *&lt;/metaFilter&gt;
                              &lt;metaFilter&gt;+run&lt;/metaFilter&gt;
                          &lt;/metaFilters&gt;
                      &lt;/configuration&gt;
                      &lt;goals&gt;
                          &lt;goal&gt;run-stories-as-embeddables&lt;/goal&gt;
                      &lt;/goals&gt;
                  &lt;/execution&gt;
              &lt;/executions&gt;
          &lt;/plugin&gt;
  </code></pre>
  
  <p>When I execute mvn mvn install -Pcoverage</p>
  
  <p>The execution goes as follows.</p>
  
  <pre><code>[INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ test-bdd-testsuite ---
  [INFO] --- jbehave-maven-plugin:3.7.5:unpack-view-resources (unpack-view-resources) @ test-bdd-testsuite ---
  [INFO] --- jacoco-maven-plugin:0.6.3.201306030806:prepare-agent (default-prepare-agent) @ test-bdd-testsuite ---
  [INFO] argLine set to -javaagent:/home/testUser/.m2/repository/org/jacoco/org.jacoco.agent/0.6.3.201306030806/org.jacoco.agent-0.6.3.201306030806-runtime.jar=destfile=/home/testUser/testProj/trunk/target/jacoco-coverage.exec
  [INFO] 
  [INFO] --- maven-compiler-plugin:2.1:compile (default-compile) @ test-bdd-testsuite ---
  [INFO] Nothing to compile - all classes are up to date
  [INFO] 
  [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ test-bdd-testsuite ---
  [debug] execute contextualize
  [INFO] Using 'UTF-8' encoding to copy filtered resources.
  [INFO] skip non existing resourceDirectory /home/testUser/testProj/trunk/src/test/resources
  [INFO] 
  [INFO] --- maven-compiler-plugin:2.1:testCompile (default-testCompile) @ test-bdd-testsuite ---
  [INFO] No sources to compile
  [INFO] 
  [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ test-bdd-testsuite ---
  [INFO] No tests to run.
  [INFO] Surefire report directory: /home/testUser/testProj/trunk/target/surefire-reports
  
  -------------------------------------------------------
   T E S T S
  -------------------------------------------------------
  
  Results :
  
  Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
  
  [INFO] 
  [INFO] --- jbehave-maven-plugin:3.7.5:run-stories-as-embeddables (embeddable-stories) @ test-bdd-testsuite ---
  [INFO] Running stories as embeddables using embedder Embedder[ .....
  
  .....
  .....
  Test execution log comes here .......
  .....
  .....
  
  [INFO] Reports view generated with 1 stories (of which 0 pending) containing 25 scenarios (of which 0 pending)
  [INFO] Meta filters excluded 0 stories and  24 scenarios
  [WARNING] Failures in reports view: 0 scenarios failed
  [INFO] 
  [INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ test-bdd-testsuite ---
  [INFO] Building jar: /home/testUser/testProj/trunk/target/test-bdd-testsuite-1.0.jar
  [INFO] 
  [INFO] --- jacoco-maven-plugin:0.6.3.201306030806:report (default-report) @ test-bdd-testsuite ---
  [INFO] 
  [INFO] --- maven-install-plugin:2.3.1:install (default-install) @ test-bdd-testsuite ---
  [INFO] Installing /home/testUser/testProj/trunk/target/test-bdd-testsuite-1.0.jar to /home/testUser/.m2/repository/com/testCode/bdd/test-bdd-testsuite/1.0/test-bdd-testsuite-1.0.jar
  [INFO] Installing /home/testUser/testProj/trunk/pom.xml to /home/testUser/.m2/repository/com/testCode/bdd/test-bdd-testsuite/1.0/test-bdd-testsuite-1.0.pom
  [INFO] ------------------------------------------------------------------------
  [INFO] BUILD SUCCESS
  [INFO] ------------------------------------------------------------------------
  [INFO] Total time: 21.134s
  [INFO] Finished at: Tue Nov 26 19:18:28 IST 2013
  [INFO] Final Memory: 14M/309M
  [INFO] ------------------------------------------------------------------------
  </code></pre>
  
  <p>With this I get a coverage report generated with the application packages. But the coverage is shown as 0%</p>
  
  <p>In the session link the application classes are not loaded.
  Screenshots:</p>
  
  <p>Can some one help me here?</p>