如何在 Cucumber 中跳過特定的測試方法執行?


我們可以藉助特徵檔案中的場景標記來跳過在 Cucumber 中執行某個特定的測試方法。

示例

特徵檔案。

@Regression
Feature: Invoice Testing
@Smoke
Scenario: Login Verification
Given User is in Home Page
@Payment
Scenario: Payment Testing
Given User is in Payment Page

帶有 Smoke 和 Payment 標記的場景的特徵檔案。

示例

import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import cucumber.api.testng.AbstractTestNGCucumberTests;
@RunWith(Cucumber.class)
@CucumberOptions(
   features = “src/test/java/features”,
   glue = “stepDefiniations”
   tags = { “~@Payment”}
)

要跳過 帶 @Payment 的場景,在 Test Runner 檔案中,在 @Payment 標記前放置 ~。

更新時間: 2020-06-11

4K+ 瀏覽

開啟您的職業生涯

完成課程以獲得認證

開始
廣告