Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97785

Code Coverage for Cucumber Tests using Jacoco

$
0
0

I am trying to integrate Jacoco to get the code coverage for my Cucumber tests using Maven. Following is my project structure:

  • -src-main-java-Pages

  • -src-main-java-Helper

  • -src-test-java-resources-features

  • -src-test-java-Steps

Following is the Jacoco configuration in my POM.xml

<plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>0.8.2</version>
            <configuration>
                <destFile>${basedir}/target/coverage-reports/jacoco.exec</destFile>
                <dataFile>${basedir}/target/coverage-reports/jacoco.exec</dataFile>
                <outputDirectory>${basedir}/target/coverage-reports/jacoco</outputDirectory>
            </configuration>
            <executions>
                <execution>
                    <id>prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                </execution>
                <execution>
                    <id>report</id>
                    <goals>
                        <goal>report</goal>
                    </goals>
                </execution>
                <execution>
                    <id>check</id>
                    <goals>
                        <goal>check</goal>
                    </goals>
                    <configuration>
                        <rules>
                            <rule>
                                <element>PACKAGE</element>
                                <includes>
                                    <include>**/*Steps.*</include>
                                </includes>
                            </rule>
                            <rule>
                                <element>PACKAGE</element>
                                <excludes>
                                    <exclude>**/*Pages.*</exclude>
                                    <exclude>**/*Page.*</exclude>
                                </excludes>
                            </rule>
                        </rules>
                    </configuration>
                </execution>
            </executions>
        </plugin>

I am able to generate the code coverage report. However, in the report, it covers all the classes in the -src-main packages. As per different google researches and SO posts, I tried to modify my POM to exclude Pages and include only Steps in my code coverage report. But somehow, it keeps on displaying all the files in the main package.

Am I taking the wrong approach? I just want to create a report which does code coverage for only the tests that I execute rather than all the files in the main package.


Viewing all articles
Browse latest Browse all 97785

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>