java - Cucumber找不到功能步骤

标签 java cucumber cucumber-jvm cucumber-java

我正在使用 Cucumber for java 进行 HelloWorld 类型的测试。

我定义了一个功能:

    Feature: To check that main tutorial course pages have loaded in TheTestRoom.com

    Scenario: To check that the WebDriver Cucumber tutorial main page has loaded
    Given I navigate to TheTestRoom.com
    When I navigate to Cucumber Tutorial page
    Then the page title should be visible

这个虚拟实现

    package step_definition;

    import cucumber.api.java.en.*;
    import cucumber.api.PendingException;

    public class myFirstStepDefinition {

            @Given("^I navigate to TheTestRoom\\ .com$")
            public void i_navigate_to_TheTestRoom_com() throws Throwable {
                    // Write code here that turns the phrase above into concrete actions
                    throw new PendingException();
            }
            @When("^I navigate to Cucumber Tutorial page$")
            public void i_navigate_to_Cucumber_Tutorial_page() throws Throwable {
                    // Write code here that turns the phrase above into concrete actions
                    throw new PendingException();
            }
            @Then("^the page title should be visible$")
            public void the_page_title_should_be_visible() throws Throwable {
                    // Write code here that turns the phrase above into concrete actions
                    throw new PendingException();
            }
    }

然后我使用编译步骤定义类并使用java来运行测试,将编译后的类路径添加到类路径

    "C:\Program Files\Java\jdk-9.0.1\bin\java" -cp "C:\OutSystems\HelloWorld\dependency\*;C:\OutSystems\HelloWorld\step_definition\*" cucumber.api.cli.Main -p pretty -g step_definition C:\OutSystems\HelloWorld\feature\

但是输出就像找不到功能步骤一样:

    Feature: To check that main tutorial course pages have loaded in TheTestRoom.com

    Scenario: To check that the WebDriver Cucumber tutorial main page has loaded [90m# features.feature:3[0m
    [33mGiven [0m[33mI navigate to TheTestRoom.com[0m
    [33mWhen [0m[33mI navigate to Cucumber Tutorial page[0m
    [33mThen [0m[33mthe page title should be visible[0m

    1 Scenarios ([33m1 undefined[0m)
    3 Steps ([33m3 undefined[0m)
    0m0.000s


    You can implement missing steps with the snippets below:

            @Given("^I navigate to TheTestRoom\\ .com$")
            public void i_navigate_to_TheTestRoom_com() throws Throwable {
                    // Write code here that turns the phrase above into concrete actions
                    throw new PendingException();
            }
            @When("^I navigate to Cucumber Tutorial page$")
            public void i_navigate_to_Cucumber_Tutorial_page() throws Throwable {
                    // Write code here that turns the phrase above into concrete actions
                    throw new PendingException();
            }
            @Then("^the page title should be visible$")
            public void the_page_title_should_be_visible() throws Throwable {
                    // Write code here that turns the phrase above into concrete actions
                    throw new PendingException();
            }

关于如何解决此问题有什么想法吗?

最佳答案

猜测,但类路径不应在第二个类路径选项中包含“step_definition”部分。假设层次结构中只有一个“step_definition”文件夹而不是两个。

关于java - Cucumber找不到功能步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47819256/

相关文章:

java - 无需 cd 在 OS X 终端中编译 java 代码

java - 需要帮助在java中对数据库中的记录进行分组

java - hibernate 。如何将自己的类映射为实体中的属性类型?

Cucumber 6.9 java8,无法从 DataTable 转换为自定义类型

cucumber - 指定cucumber中的特征文件位置

.net - BDD测试框架

java - 如何在新的浏览器实例中运行每个 cucumber 功能?

Cucumber 测试 - 将场景大纲的示例表分成更小的 block

java - 放心 : Making a GET request with a parameters map

java - 使用 jsch 连接到 azure 中托管的 sftp 服务器时连接重置