我在一个项目中工作,该项目实现了一个简单的功能,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类与我的功能有关!
我不明白我实现了方法脚本的问题
最佳答案
这意味着Cucumber无法找到您的粘合代码(步骤定义)。
对于胶水而不是glue={"stepsdef"},
,请提供stepsdef
的路径。
顺便说一句,建议将功能文件放在src / test / resources中:)
如果无法正常使用,请尝试cucumber-java-skeleton;它旨在“开箱即用”地工作,并且比设置自己的项目更容易使用。
如果您确实想设置自己的项目,请查看此blogpost,它应该指导您完成设置项目并将文件放在正确目录中的步骤...