如何在 Cucumber 中不使用示例进行单数据参数化?
cucumbersoftware testingautomation testing更新于 2026/2/10 11:52:17
我们可以在 Cucumber 中不使用示例进行单数据参数化, 方法是直接在特征文件中传递值。
示例
特征文件。
Feature: Tutorialpoint Job page Scenario: Tutorialpoint job page look and fee Given Launch site https://www.tutorialspoint.com/about/about_careers.htm Then Verify the tabs on the page
URL 直接在功能文件中的 Given 语句中传递。
步骤定义文件应该包含 Given 语句的映射。
示例
@Given (“^Launch site \"([^\"]*)\"$”)
public void launchJobsite(String url){
System.out.println("url is : " + url);
}
@Then (“^Verify the tabs on the page"$”)
public void tabverification(){
System.out.println("Tabs verified successfully);
}
@Given (“^Launch site \"([^\"]*)\"$”) 在运行时传递 UR。

