如何在 Cucumber 测试用例集中包含和排除测试方法?

cucumbersoftware testingautomation testing

我们可以通过在特性文件中标记场景来在 Cucumber 测试用例集中包含和排除测试方法。

示例

特性文件。

@Tutorialspoint Testing
Feature: Login Feature Testing
@Smoke
Scenario: Home Page Testing
Given User is in home page
@CodingModule
Scenario: Coding Module Testing
Given User is in Coding Module Page

测试运行器文件包含标签"Smoke",用于排除执行;同时包含标签"CodingModule",用于包含在执行过程中。

示例

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 = {“~@Smoke”, “@CodingModule”}
)

相关文章