我在项目中工作,我实现了一个简单的功能,stepdefinition类和运行器,并希望使用testJUnit或运行TestNG.xml进行测试。
但我有这个问题
You can implement missing steps with the snippets below:
@Given("^sample feature file is ready$")
public void sample_feature_file_is_ready() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@When("^I run the feature file$")
public void i_run_the_feature_file() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
@Then("^run should be successful$")
public void run_should_be_successful() throws Throwable {
// Write code here that turns the phrase above into concrete actions
throw new PendingException();
}
我的功能是:
@smokeTest
Feature: To test my cucumber test is running
I want to run a sample feature file.
Scenario: cucumber setup
Given sample feature file is ready
When I run the feature file
Then run should be successful
我的步骤定义是:
public class Test_Steps {
@Given("^sample feature file is ready$")
public void givenStatment(){
System.out.println("Given statement executed successfully");
}
@When("^I run the feature file$")
public void whenStatement(){
System.out.println("When statement execueted successfully");
}
@Then("^run should be successful$")
public void thenStatment(){
System.out.println("Then statement executed successfully");
}
我的跑步者是:
@RunWith(Cucumber.class)
@CucumberOptions(
features = {"D:\\feat\\user"},
glue={"stepsdef"},
tags= "@smokeTest")
public class RunnerTestInChrome extends AbstractTestNGCucumberTests {
}
我怎么知道stepdefinition类与我的功能有关! 我不了解我实现方法脚本的问题
答案 0 :(得分:1)
这意味着Cucumber无法找到您的胶水代码(步骤定义)。
胶水代替glue={"stepsdef"},
提供stepsdef
的路径。
顺便说一句,建议您在src / test / resources中使用您的功能文件:)
如果您无法使用它,请尝试cucumber-java-skeleton;它设计为“开箱即用”,比设置自己的项目更容易使用。
如果您确实想要设置自己的项目,请查看此blogpost,它将指导您完成设置项目和将文件放在正确目录中的步骤......