Cucumber 的主要檔案元件有哪些?
Cucumber 中的主要檔案元件列舉如下 −
特性檔案 − 此檔案具有 .feature 的副檔名。它包含以純文字形式呈現的單個或多個測試場景。所有場景都使用如下關鍵字編寫:Then、Given、When、And、But、Feature、Background 等。
示例
特性檔案。
Feature: Login Test Scenario: Tutorialspoint login validation Given: Launch the “https://tutorialspoint.tw/index.htm”
步驟定義檔案 - 此檔案具有 .java 的副檔名。它提供測試場景到測試指令碼邏輯的對映。
示例
基於上述特性檔案的步驟定義檔案。
@Given (“^Launch the \"([^\"]*)\"$”)
public void launch_application(String url){
System.out.println("The url is : " + url);
}測試執行器檔案 - 此檔案具有 .java 的副檔名。它充當步驟定義檔案和特性檔案之間的紐帶。它提供選擇單個特性檔案或多個特性檔案的選項。它包含步驟定義檔案的路徑和特性檔案的路徑。
示例
測試執行器檔案
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
@CucumberOptions(
features = "src/test/java/features",
glue="stepDefinations")
public class TestRunner extends AbstractTestNGCucumberTests { }
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP