Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emma code coverage, source file not found in sourcepath

Tags:

java

maven

emma

To generate emma report I ran these command.

  1. mvn install -Pwith-emma 
  2.  java -cp %USERPROFILE%/.m2/repository/emma/emma/2.1.5320/emma-2.1.5320.jar emma report -r xml,html -in coverage.ec -in target/coverage.em

After ran command I am able to generate emma report and also able excluding packages as I want, And it give me whole class coverage report. But the issue is when I click on any particular class to see file report(code coverage) I am getting:

[source file 'com/test/test.java' not found in sourcepath] When I generate emma report.

Here is the my pom.xml entry regarding emma-maven-plugin<

 <profile>
        <id>with-emma</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>emma-maven-plugin</artifactId>
                    <inherited>true</inherited>
                    <executions>
                        <execution>
                            <id>instrument</id>
                            <phase>process-test-classes</phase>
                             <configuration>
                               <filters>
                                    <filter>-com.test.generated.ceq.*</filter>
                                       <filter>-com.activities.*</filter>
                                </filters>
                      </configuration>
                            <goals>
                                <goal>instrument</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

After checked many link I feel there is issue with command

 2.  java -cp %USERPROFILE%/.m2/repository/emma/emma/2.1.5320/emma-2.1.5320.jar emma report -r xml,html -in coverage.ec -in target/coverage.em

But tried many but not able to resolve this issue. Thanks.

like image 373
Dani Avatar asked Mar 26 '14 10:03

Dani


1 Answers

AFAIK, you should add in the 'emma report' command line the -sp flag to include the sources in the report:

java -cp %USERPROFILE%/.m2/repository/emma/emma/2.1.5320/emma-2.1.5320.jar emma report -r xml,html -sp /<path-to-project>/src/main/java/ -sp /<path-to-another-project>/src/main/java/ -in coverage.ec -in target/coverage.em
like image 66
shlomi33 Avatar answered Oct 28 '22 10:10

shlomi33