测试框架意外退出错误 - 黄瓜Java IntelliJ

时间:2016-10-27 13:36:36

标签: cucumber cucumber-java

我很想在IntelliJ中运行一个简单的Cucumber脚本。现在解决所有依赖问题后,当我运行方案时,我收到错误: 测试框架意外退出

测试于下午4:34开始......

    Testing started at 4:34 PM ...
Exception in thread "main" java.lang.ClassNotFoundException: cucumber.cli.Main
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:195)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)

Process finished with exit code 1

这是我的pom.xml:

 <dependencies>


        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.4</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <scope>test</scope>
            <version>1.2.4</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.4</version>
        </dependency>


        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.5</version>
        </dependency>


        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>gherkin</artifactId>
            <version>2.12.2</version>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>


        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-jvm</artifactId>
            <version>1.0.11</version>
            <type>pom</type>
        </dependency>

    </dependencies>

功能文件:

 Feature: SomeFeature

Scenario: Verify Data
  Given I receive message
  When System process message
  Then Verify message posted to DB

步骤定义文件:

    public class Test {
    @Given("^I receive message$")
    public void I_receive_message() throws Throwable {
        System.out.print("Given....");
    }

    @When("^System process message$")
    public void System_process_message() throws Throwable {
       System.out.print("When");
    }

    @Then("^Verify message posted to DB$")
    public void Verify_message_posted_to_DB() throws Throwable {
        System.out.print("Then...");
    }
}

请帮我解决这个问题。已经浪费了很多时间。

1 个答案:

答案 0 :(得分:0)

我想知道这是否与你发射黄瓜的方式有关。试试这个:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>exec-maven-plugin</artifactId>
  <version>1.4.0</version>
  <executions>
    <execution>
      <id>default-cli</id>
      <phase>integration-test</phase>
      <goals>
        <goal>exec</goal>
      </goals>
      <configuration>
        <executable>java</executable>
        <arguments>
          <argument>-classpath</argument>
          <classpath/>
          <argument>cucumber.api.cli.Main</argument>
          <argument>--strict</argument>
          <argument>--glue</argument>
          <argument>insert.my.mappings.package.here</argument>
          <argument>--plugin</argument>
          <argument>json:${project.build.directory}/cucumber.json</argument>
          <argument>--plugin</argument>
          <argument>html:${project.build.directory}/cucumber</argument>
          <argument>--tags</argument>
          <argument>~@ignore</argument>
          <argument>src/main/features/${feature}</argument>
        </arguments>
    </execution>
  </executions>
</plugin>