如何為 Cucumber 使用測試執行器檔案執行測試?
我們可以為 Cucumber 使用測試執行器檔案執行測試。測試執行器檔案應包含我們想要執行的功能檔案和步驟定義檔案的路徑。
功能檔案的程式碼實現
功能 ;− 登入模組
場景 − 歡迎頁面登入驗證
假定使用者在歡迎頁面
然後應該顯示歡迎頁面
示例
步驟定義檔案的程式碼實現
package stepDefinations;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
public class stepDefination {
@Given("^User is on Welcome Page$")
public void user_on_welcome_page() {
System.out.println("User on welcome page");
}
@Then("^Welcome page should be displayed$")
public void verify_user_on_welcome_page() {
System.out.println("User should be on welcome page");
}
}測試執行器檔案的程式碼實現
package cucumberOptions;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(
//path of feature file
features = "src/test/java/features/Login.feature",
//path of step definition file
glue = "stepDefination"
)
public class TestRunner {
}專案結構

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 語言程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP