0
votes

Please find my Pom.xml

4.0.0

<groupId>Cucumberreports</groupId>
<artifactId>Cucumberreports</artifactId>
<version>0.0.1-SNAPSHOT</version>

<name>Cucumberreports</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.7</maven.compiler.source>
    <maven.compiler.target>1.7</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>


    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-java</artifactId>
        <version>6.11.0</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>6.11.0</version>
        <scope>test</scope>
    </dependency>


    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-picocontainer</artifactId>
        <version>6.11.0</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/net.masterthought/cucumber-reporting -->
    <!-- https://mvnrepository.com/artifact/net.masterthought/maven-cucumber-reporting -->
    <dependency>
        <groupId>net.masterthought</groupId>
        <artifactId>maven-cucumber-reporting</artifactId>
        <version>5.5.4</version>
    </dependency>



</dependencies>

<build>
    <pluginManagement><!-- lock down plugins versions to avoid using Maven 
            defaults (may be moved to parent pom) -->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <includes>
                        <include>**/CucumberRunner*.java</include>
                    </includes>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>

            </plugin>
            
            
            <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
            <version>5.5.4</version>
            <executions>
                <execution>
                    <id>execution</id>
                    <phase>verify</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                    <configuration>
                        <projectName>Cucumberreports</projectName>
                        <!-- optional, per documentation set this to "true" to bypass generation of Cucumber Reports entirely, defaults to false if not specified -->
                        <skip>false</skip>
                        <!-- output directory for the generated report -->
                        <outputDirectory>target/cucumber-reports/advanced-reports</outputDirectory>
                        <!-- optional, defaults to outputDirectory if not specified -->
                        <inputDirectory>target/cucumber-reports/cucumber.json</inputDirectory>
                        <jsonFiles>
                            <!-- supports wildcard or name pattern -->
                            <param>**/*.json</param>
                        </jsonFiles>
                        <!-- optional, defaults to outputDirectory if not specified -->
                        <classificationDirectory>${project.build.directory}/cucumber-reports</classificationDirectory>
                        <classificationFiles>
                                <!-- supports wildcard or name pattern -->
                                <param>sample.properties</param>
                                <param>other.properties</param>
                        </classificationFiles>
                        <parallelTesting>false</parallelTesting>
                        <!-- optional, set true to group features by its Ids -->
                        <mergeFeaturesById>false</mergeFeaturesById>
                        <!-- optional, set true to get a final report with latest results of the same test from different test runs -->
                        <mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
                        <!-- optional, set true to fail build on test failures -->
                        <checkBuildResult>false</checkBuildResult>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        </plugins>
    </pluginManagement>
</build>

Runner Class -

package Cucumberreports.Cucumberreports;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber; import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber.class) @CucumberOptions( features = {"C:\Users\rishabh Patel\eclipse-workspace\Cucumberreports\Feature"}, glue = {"Stepdefinition"}, plugin = {"pretty", "json:target/cucumber-reports/cucumber.json"} //monochrome= true

    )

public class CucumberRunner {

}

PFA Screenshot

enter image description here

Please let me know if more details are needed.richa ahuja
So what have you tried and observed? Maven has a few phases. When you run mvn test the json file should be created. Is it there?M.P. Korstanje