Nandan Dubey
Nandan Dubey

Reputation: 1

why i am getting 0% code coverage for jacoco test report?

I am getting 0% code coverage in as shown in image though test cases have been generated successfully but I want report also.

note: I am using OSGI framework and java 11

screenshot

below is my pom.xml configuration

<dependency>
        <groupId>org.evosuite</groupId>
        <artifactId>evosuite-standalone-runtime</artifactId>
        <version>1.1.0</version>  <!-- You can use any version name here -->
        <scope>system</scope>  <!-- This tells Maven to use the JAR from the
        file system -->
        <systemPath>
            C:\project-folder\evosuite-1.1.0.jar</systemPath> <!--
        Hardcoded path -->
    </dependency>

<plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>3.2.0</version>
        </plugin>
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.5</version>
            <configuration>
                <filesets>
                    <fileset>
                        <directory>node</directory>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                    <fileset>
                        <directory>node_modules</directory>
                        <followSymlinks>false</followSymlinks>
                    </fileset>
                </filesets>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>${maven-bundle-plugin.version}</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                    <Bundle-Version>${project.version}</Bundle-Version>
                    <Bundle-Activator>com.package.Activator</Bundle-Activator>
                    <Export-Package>
                        com.package;version=${project.version},com.package.exception*;version=${project.version},com.package.data*;version=${project.version},com.package*;version=${project.version}</Export-Package>
                    <Import-Package>*</Import-Package>
                </instructions>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version>
            <executions>
                <execution>
                    <id>run-evosuite</id>
                    <phase>generate-test-sources</phase> <!-- The correct
                    Maven phase for test generation -->
                    <goals>
                        <goal>exec</goal>
                    </goals>
                    <configuration>
                        <executable>java</executable>
                        <arguments>
                            <argument>-jar</argument>
                            <argument>
                                C:\project-folder\evosuite-1.1.0.jar</argument>
                            <argument>-class</argument>
                            <argument>
                                com.package.Java</argument>
                            <argument>-projectCP</argument>
                            <argument>${project.build.outputDirectory}</argument>
                            <argument>-Dtest_dir=src/test/java</argument>
                        </arguments>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.12</version> <!-- You can update this to the latest
            version if needed -->
            <executions>
                <!-- This prepares the JaCoCo agent -->
                <execution>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <!-- This generates the coverage report -->
                <execution>
                    <id>report</id>
                    <phase>verify</phase>  <!-- This runs after the tests have
                    executed -->
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

"I am currently facing an issue where the code coverage is showing 0% despite the fact that all the test cases have been generated and executed successfully. I am working within the OSGI framework and using Java 11 for development. While the tests seem to be running without any problems, the coverage report does not reflect the actual test execution and shows no coverage at all. What I am expecting is a proper code coverage report that accurately reflects the lines of code being tested, including relevant details like branch coverage and method coverage. Additionally, I would like to understand why the report is failing to generate or show any coverage, even though the tests have clearly been executed. It’s important to me that the coverage tool integrates seamlessly with my current setup, as I need to ensure that every part of the application is well tested. I'm not looking for a solution at this point, just trying to gain a better understanding of the potential reasons why this might be happening."

commands i am running

  1. mvn clean install
  2. mvn dependency:build-classpath "-DincludeScope=runtime" "-Dmdep.outputFile=classpath.txt"
  3. java -jar C:\project-folder\evosuite-1.1.0.jar -projectCP "$(type classpath.txt)" -target C:\project-folder\com.package\target\classes -Dtest_dir=src/test/java
  4. mvn clean install
  5. mvn test
  6. mvn clean test jacoco:report

Upvotes: 0

Views: 133

Answers (0)

Related Questions