JUnit Cucumber无法找到步骤 [英] JUnit Cucumber cannot find steps

查看:135
本文介绍了JUnit Cucumber无法找到步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行"mvn test"命令期间,我收到以下错误消息:

During the execution of the "mvn test" command, I obtain this error message :

7 Scenarios (7 undefined)
31 Steps (31 undefined)
0m0,000s

You can implement missing steps with the snippets below...

尽管如此,所有这些步骤在我的文件中都定义得很好,并且与错误消息中提出的摘要非常吻合!

Nevertheless all this steps is defined well in my files and correspond well to snippets proposed in the error message !

这是我的黄瓜赛跑者:

@RunWith(ExtendedCucumber.class)

@ExtendedCucumberOptions(jsonReport = "target/cucumber.json", retryCount = 3, detailedReport = true, detailedAggregatedReport = true, overviewReport = true, jsonUsageReport = "target/cucumber-usage.json", usageReport = true, toPDF = true, outputFolder = "target")

@CucumberOptions(plugin = { "html:target/cucumber-html-report", "json:target/cucumber.json", "pretty:target/cucumber-pretty.txt",
    "usage:target/cucumber-usage.json", "junit:target/cucumber-results.xml" }, features = { "src/test/resources" }, glue = { "src/test/java" })

public class CucumberTest {}

我有多个功能文件和多个步骤定义文件.

I have multiple feature files and multiple step definitions files.

我的依赖项:

<properties>
    <cucumber.version>1.2.5</cucumber.version>
    <jdk.version>1.8</jdk.version>
</properties>

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java8</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-spring</artifactId>
            <version>${cucumber.version}</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.github.mkolisnyk</groupId>
            <artifactId>cucumber-runner</artifactId>
            <version>1.3.3</version>
        </dependency>
    </dependencies>

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-junit47</artifactId>
                        <version>2.20</version>
                    </dependency>
                </dependencies>
            </plugin>

        </plugins>
    </build>

有什么想法吗?

提前谢谢

推荐答案

glue = { "src/test/java" }的值必须是程序包名称,而不是路径名.

The value for glue = { "src/test/java" } must be the package name, instead of the path name.

如果步骤定义类位于包steps中(因此它们存储在路径src/test/java/steps中),则值必须为glue = { "steps" }.

If your step definition classes are in the package steps (so they are stored in the path src/test/java/steps) the value must be glue = { "steps" }.

这篇关于JUnit Cucumber无法找到步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆