[英]can't run TestNG or JUnit test
我在一個項目中工作,該項目實現了一個簡單的功能,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中:)
如果無法正常工作,請嘗試cumber-java-skeleton ; 它旨在“開箱即用”地工作,並且比設置自己的項目更容易使用。
如果您確實想設置自己的項目,請查看此博客文章 ,該文章應指導您完成設置項目的步驟,並將文件保存在正確的目錄中...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.