Rauf Mirzayev
Rauf Mirzayev

Reputation: 51

Cucumber jvm report doesnt generating

I want to get cucumber report, but it nothing generates. I get this error during running via mvn clean install. I cant to resolve this issue. I'm new in automation...

/* During run as Maven Clean Install I get mentioned below error:

    [INFO] Scanning for projects...
    [INFO] 
    [INFO] -----------------< MobWebAutomation:MobWebAutomation >------------------
    [INFO] Building MobWebAutomation 1.0-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] 
    [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ MobWebAutomation ---
    [INFO] Deleting C:\Users\Rauf.mirzoyev\eclipse-workspace_Appium\MobWebAutomation\target
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MobWebAutomation ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.8.0:compile (default-compile) @ MobWebAutomation ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ MobWebAutomation ---
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 1 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ MobWebAutomation ---
    [INFO] Changes detected - recompiling the module!
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 4 source files to C:\Users\Rauf.mirzoyev\eclipse-workspace_Appium\MobWebAutomation\target\test-classes
    [ERROR] /C:/Users/Rauf.mirzoyev/eclipse-workspace_Appium/MobWebAutomation/src/test/java/stepDefinitions/RegistrationWithValidCredentials.java:[116,55] unmappable character (0x8F) for encoding windows-1252
    [ERROR] /C:/Users/Rauf.mirzoyev/eclipse-workspace_Appium/MobWebAutomation/src/test/java/stepDefinitions/RegistrationWithValidCredentials.java:[116,61] unmappable character (0x8F) for encoding windows-1252
    [ERROR] /C:/Users/Rauf.mirzoyev/eclipse-workspace_Appium/MobWebAutomation/src/test/java/stepDefinitions/RegistrationWithValidCredentials.java:[116,64] unmappable character (0x8F) for encoding windows-1252
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ MobWebAutomation ---
    [INFO] 
    [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ MobWebAutomation ---
    [INFO] Building jar: C:\Users\Rauf.mirzoyev\eclipse-workspace_Appium\MobWebAutomation\target\MobWebAutomation-1.0-SNAPSHOT.jar
    [INFO] 
    [INFO] --- maven-cucumber-reporting:5.0.0:generate (execution) @ MobWebAutomation ---
    [INFO] About to generate Cucumber report.
    Dec 29, 2021 10:31:50 AM net.masterthought.cucumber.ReportBuilder generateErrorPage
    INFO: Unexpected error
    net.masterthought.cucumber.ValidationException: None report file was added!
        at net.masterthought.cucumber.ReportParser.parseJsonFiles(ReportParser.java:62)
        at net.masterthought.cucumber.ReportBuilder.generateReports(ReportBuilder.java:88)
        at net.masterthought.cucumber.CucumberReportGeneratorMojo.execute(CucumberReportGeneratorMojo.java:209)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  7.525 s
    [INFO] Finished at: 2021-12-29T10:31:51+04:00
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal net.masterthought:maven-cucumber-reporting:5.0.0:generate (execution) on project MobWebAutomation: Error Found: BUILD FAILED - Check Report For Details -> [Help 1]
    [ERROR] 
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR] 
    [ERROR] For more information about the errors and possible solutions, please read the 

following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

     */
    

    
    /*My pom file:*/
    
  {  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>MobWebAutomation</groupId>
        <artifactId>MobWebAutomation</artifactId>
        <version>1.0-SNAPSHOT</version>
    
        <dependencies>
    
            <dependency>
                <groupId>io.appium</groupId>
                <artifactId>java-client</artifactId>
                <version>7.2.0</version>
            </dependency>
    
    
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-java</artifactId>
                <version>7.1.0</version>
            </dependency>
    
            <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
            <dependency>
                <groupId>io.cucumber</groupId>
                <artifactId>cucumber-junit</artifactId>
                <version>7.0.0</version>
                <scope>test</scope>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    
    
        </dependencies>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.0</version>
                    <configuration>
                        <includes>
                            <exclude>**/*Runner.java</exclude>
                        </includes>
                    </configuration>
                </plugin>
                
    
    
    <plugin>
            <groupId>net.masterthought</groupId>
            <artifactId>maven-cucumber-reporting</artifactId>
             <version>5.0.0</version>
            <executions>
              <execution>
                <id>execution</id>
                <phase>verify</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
                <configuration>
                  <projectName>MobWebAutomation</projectName>
                  <outputDirectory>${project.build.directory}/cucumber-reports</outputDirectory>
                    <enableFlashCharts>true</enableFlashCharts>
                    <buildNumber>42</buildNumber> 
                   <parallelTesting>false</parallelTesting>
                    <inputDirectory>${project.build.directory}/cucumber-reports</inputDirectory>
                  <jsonFiles>
                  <jsonFile>**/*.json</jsonFile>
                  </jsonFiles>
                  <testFailureIgnore>true</testFailureIgnore>
                  <buildSuccessOnTestFailure>true</buildSuccessOnTestFailure>
                </configuration>
              </execution>
            </executions>
          </plugin>
            </plugins>
        </build>
    
    </project>
    
    }

    **Runner class** 
    
   { package runner;
    
    import org.junit.runner.RunWith;
    import io.cucumber.junit.CucumberOptions;
    import io.cucumber.junit.Cucumber;
    
    
    @RunWith(Cucumber.class)
    @CucumberOptions(features = { "src/test/java/features/registration.feature" }, 
                    glue = { "stepDefinitions",
                    "utility" }, monochrome = true, plugin = { "pretty",
                    
                    "json:target/cucumber-reports/AutomationReport.json",
                    "json:target/cucumber-reports/cucumber.runtime.formatter.JSONFormatter"
                    
                    
                    
                    }, 
                    dryRun = false)//, tags = "@correct or @incorrect")
    
    public class RunTest  {
    
    }

Upvotes: 2

Views: 3667

Answers (2)

Amit Shelar
Amit Shelar

Reputation: 11

Following Configuration helped me to resolve the issue

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>qaclickacademy</groupId>
  <artifactId>RestAPIFramework</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>RestAPIFramework</name>
  <url>http://maven.apache.org</url>
  
  <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
  </properties>
    
  <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>3.0.0-M7</version>
          <configuration>
            <testFailureIgnore>true</testFailureIgnore>
          </configuration>
        </plugin>
        
        <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>5.3.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>cucumber-jvm-example</projectName>
                            <jsonFiles>
                                <param>**/*.json</param>
                            </jsonFiles>
                            <outputDirectory>${project.build.directory}/advanced-reports</outputDirectory>
                            <inputDirectory>${project.build.directory}/cucumber-reports</inputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
      </plugins>
  </build>
  
  <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>7.5.0</version>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-junit</artifactId>
        <version>7.5.0</version>
        <scope>test</scope>
    </dependency>
    
    <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
    <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-core</artifactId>
        <version>7.5.0</version>
    </dependency>
  </dependencies>
</project>

TestRunner Class

@RunWith(Cucumber.class)
@CucumberOptions(features="src/test/java/features", glue= {"stepDefinations"},
                monochrome = true,
                plugin = {"pretty",
                          "json:target/cucumber-reports/reports.json",
                          "json:target/cucumber-reports/cucumber.runtime.formatter.JSONFormatter"})

                
public class TestRunner {

}

Upvotes: 1

Rauf Mirzayev
Rauf Mirzayev

Reputation: 51

Thank you to all, and especially to Raghav Pal, and his YouTube channel.

After all steps, it was needed to perform "clean verify". After this operation, the report has been successfully generated.

Updated POM.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>MobWebAutomation</groupId>
    <artifactId>MobWebAutomation</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source> /* 1.8 it's your JDK version */
        <maven.compiler.target>1.8</maven.compiler.target>/* 1.8 it's your JDK version */
    </properties>

    <dependencies>
        <dependency>
            <groupId>io.appium</groupId>
            <artifactId>java-client</artifactId>
            <version>7.2.0</version>
        </dependency>

        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>7.1.0</version>
        </dependency>

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

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.0</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>net.masterthought</groupId>
                <artifactId>maven-cucumber-reporting</artifactId>
                <version>2.8.0</version>
                <executions>
                    <execution>
                        <id>execution</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <projectName>YOUR_PROJECT_Name</projectName>
                            <outputDirectory>${project.build.directory}/cucumber-report-html</outputDirectory>
                            <cucumberOutput>${project.build.directory}/cucumber.json</cucumberOutput>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

RUNNER CLASS:

package runner;
import org.junit.runner.RunWith;

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

@RunWith(Cucumber.class)
@CucumberOptions(
    features = { "src/test/java/features/registration.feature" }, 
    glue = { "stepDefinitions", "utility" },
    monochrome = true,
    plugin = {
        "pretty",
        "json:target/Cucumber.json"                     
    }, 
    dryRun = false
) 
public class RunTest  {
    //
}

After you need to clean your project -> run via mvn clear verify. That's all.

Source: YouTube video - Selenium Cucumber Java BDD Framework 12 | How To Create HTML Reports

Upvotes: 3

Related Questions