gpt4 book ai didi

java - Cucumber找不到功能步骤

转载 作者:行者123 更新时间:2023-12-01 20:03:02 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com