我正在使用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();
}
有关如何解决此问题的任何想法?
答案 0 :(得分:3)
猜测但是类路径不应该在第二个类路径选项中包含“step_definition”部分。基于这样的假设:假设在层次结构中只有一个“step_definition”文件夹而不是两个。