我有一些使用Gherkin语法编写的SpecFlow功能,我想暂时禁用该功能,以防止其测试运行。
是否有属性可用于标记该功能以实现此操作? 我猜想在Cucumber中起作用的某些东西也可以在SpecFlow中使用。
您可以使用标签@ignore来标记该特性:
@ignore @web
Scenario: Title should be matched
When I perform a simple search on 'Domain'
Then the book list should exactly contain book 'Domain Driven Design'
@ignore("reason for ignoring")
编辑:由于某种原因,它会在空格处中断,但这样做可以解决:
@ignore("reason")
正如jbandi所建议的那样,您可以使用@ignore标签。
该标签可应用于:
假设NUnit是测试提供程序,则生成的代码中的结果是将
[NUnit.Framework.IgnoreAttribute()]
插入到方法或类中。
Feature: CheckSample
@ignored
Scenario Outline: check ABC #checkout.feature:2
Given I open the applciation
When I enter username as "<username>"
And I enter password as "<password>"
Then I enter title as "<title>"
Examples:
| username | password |
| dude | daad |
请将上述内容视为“CheckSample.feature”功能文件。
以下是您的步骤文件,仅为部分文件:
public class Sampletest {
@Given("^I open the applciation$")
public void i_open_the_applciation() throws Throwable {
// Write code here that turns the phrase above into concrete actions
//throw new PendingException();
}
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = {"pretty", "html:target/reports",
"json:target/reports/cucumber-report.json"},
monochrome = true,
tags = {"~@ignored"}
)
public class junittestOne {
public static void main(String[] args) {
JUnitCore junit = new JUnitCore();
Result result = junit.run(junittestOne.class);
}
}
如果你不想运行某个特性文件,可以在场景前面写上 @smoke。 然后,在 Runner 文件中,写上 tag = "not @smoke"。 这样就会运行所有的特性文件,但不包括你标注为 @smoke 的那一个。
@ignore
。 - nitzel