Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 通过Maven从命令提示符运行Cucumber测试_Java_Maven_Intellij Idea_Junit_Cucumber - Fatal编程技术网

Java 通过Maven从命令提示符运行Cucumber测试

Java 通过Maven从命令提示符运行Cucumber测试,java,maven,intellij-idea,junit,cucumber,Java,Maven,Intellij Idea,Junit,Cucumber,我有一个基于Maven的Cucumber测试设置,使用IntelliJ中的功能文件测试一个基本Java应用程序。在IntelliJ中运行时,所有这些都可以正常工作-从我的功能文件中,我可以运行所有场景或单个场景。从顶部的运行选项(图标)运行时,它也可以正常运行(不确定您如何称呼它们) 我希望能够通过Maven(在IntelliJ中)在测试时单击并从命令提示符mvn Test运行它们。我正在使用Maven SureFire插件 当我运行“mvn测试”(cmd提示符或直接在IntelliJ中运行)时

我有一个基于Maven的Cucumber测试设置,使用IntelliJ中的功能文件测试一个基本Java应用程序。在IntelliJ中运行时,所有这些都可以正常工作-从我的功能文件中,我可以运行所有场景或单个场景。从顶部的运行选项(图标)运行时,它也可以正常运行(不确定您如何称呼它们)

我希望能够通过Maven(在IntelliJ中)在测试时单击并从命令提示符mvn Test运行它们。我正在使用Maven SureFire插件

当我运行“mvn测试”(cmd提示符或直接在IntelliJ中运行)时,我不再收到相同的错误,但没有执行cucumber特性测试。当我尝试直接在IntelliJ中运行我的runner文件时,这会给我一个错误:io.cumber.core.options.RuntimeOptionsBuilder.enablePublishPlugin()Lio/cumber/core/options/RuntimeOptionsBuilder

我在ExternalLibraries部分检查了该类,然后转到指定的路径和类(RuntimeOptions Builder)。而且,没有所谓的“enablePublishPlugin()”方法-至少这是正确的,我不知道为什么它会丢失

项目结构: 我正在测试的java应用程序位于同一个项目中:'src/main/java.

黄瓜设置:

步骤定义:

  • src/test/java/com/step\u定义>
    • VendingMachinePurchaseTest(我的步骤定义文件)
    • TestRunnerTest(测试运行程序文件)
特点:

  • src/test/resources/features>
    • 自动售货机采购测试功能

我的POM文件: 我想我已经阅读了网络上的每一条关于这一点的帖子,并尝试了很多东西和各种各样的东西……然后还有更多。很可能是一些非常简单和愚蠢的事情。我真的非常感谢你的帮助


提前感谢。

这可能是一个依赖性问题,但很难看出问题所在。某些依赖项是可传递的,不应在pom文件中声明。Cucumber还更改了groupId,所以我不会将这两个不同的版本混用。嗨,John,谢谢你的回复。我删除了cucumber core的InfoCukes版本,但仍然是相同的错误。
<?xml version="1.0" encoding="UTF-8"?>
<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>com.machine</groupId>
    <artifactId>VendingMachine</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <project.build.sourceEncoding>UTF8</project.build.sourceEncoding>
    </properties>

    <pluginRepositories>
        <pluginRepository>
            <id>Codehaus repository</id>
            <url>http://insecure.repo1.maven.org/maven2/</url>
        </pluginRepository>
    </pluginRepositories>


    <dependencies>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>6.1.2</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>6.1.2</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-jvm-deps</artifactId>
            <version>1.0.6</version>
            <scope>provided</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/net.jodah/typetools -->
        <dependency>
            <groupId>net.jodah</groupId>
            <artifactId>typetools</artifactId>
            <version>0.6.1</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/datatable-dependencies -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>datatable</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>datatable-dependencies</artifactId>
            <version>3.0.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/javax.money/money-api -->
        <dependency>
            <groupId>javax.money</groupId>
            <artifactId>money-api</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-core</artifactId>
            <version>1.2.5</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
            <version>20.1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-webapp</artifactId>
            <version>9.4.34.v20201102</version>
        </dependency>
        <dependency>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5-20081211</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-picocontainer -->
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-picocontainer</artifactId>
            <version>6.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.1</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>io.cucumber</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>6.8.2</version>
            <scope>compile</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
        <dependency>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.maven.surefire/surefire-junit -->
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit</artifactId>
            <version>2.6</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.7.0</version>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.junit.platform/junit-platform-launcher -->
        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.7.0</version>
            <scope>test</scope>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>
package com.step_definitions;

import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(value = Cucumber.class)
@CucumberOptions(
        plugin={ "pretty", "html:target/report" },
        monochrome = true
)

public class TestRunnerTest {
}