运行Test Runner类时发生错误-java.lang.NoClassDefFoundError:gherkin / formatter / Reporter

时间:2019-01-30 13:14:59

标签: maven selenium-webdriver junit cucumber pom.xml

运行TestRunner文件时出错

Java.lang.NoClassDefFoundError: gherkin/formatter/Reporter
    at java.base/java.lang.ClassLoader.defineClass1(Native Method)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1016)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/

将所有依赖项更新为当前版本

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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>latest</groupId>
      <artifactId>corp</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>corp</name>
      <url>http://maven.apache.org</url>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>

      <dependencies>
      <dependency>
    <groupId>com.vimalselvam</groupId>
    <artifactId>cucumber-extentsreport</artifactId>
    <version>3.0.1</version>
    </dependency>
    <dependency>
        <groupId>com.aventstack</groupId>
        <artifactId>extentreports</artifactId>
        <version>3.0.7</version>
        <scope>provided</scope>
    </dependency>
      <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-email</artifactId>
        <version>1.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.directory.studio</groupId>
        <artifactId>org.apache.commons.io</artifactId>
        <version>2.4</version>
    </dependency>
        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.12</version>
        </dependency>
        <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.141.59</version>
    </dependency>
    <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>4.2.2</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>4.2.2</version>
        </dependency>

      </dependencies>

      <build>
        <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.0.0-M3</version>
    <!--    <configuration>
        <includes>
        <excludes>**/*TestRunnertest.java</excludes>
        </includes>
        </configuration> -->
        </plugin>

                  <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>
                       <encoding>UTF-8</encoding>          
                    </configuration>
                  </plugin>   

      </plugins>
      </build>
    </project>

1 个答案:

答案 0 :(得分:0)

一些研究可以帮助您 已经noticed

此问题出来由于硒和小黄瓜的不相容组合 依赖性。尝试更改该问题的小黄瓜依赖版本 解决。 这是可能对您有帮助的建议版本

  

使用黄瓜2.4.0和5.1.0小黄瓜

并也检查此link