功能文件
@ActivateSegment
Feature: Test for Activate segment
Scenario: Login
Given I navigate to M
And I enter user name
And I enter password
And I login to MM
Scenario: Open grid
Given I choose menu
And I choose Segments menu
Scenario: Open segment creation page
Given I click on New button
And I click on Segment button
答案 0 :(得分:19)
使用代码~@tag_name
排除具有特定标记的方案
cucumber --tags ~@tag_name
注意我使用了~
符号。
这里需要注意的一点是,如果你的@ wip-tagged场景通过,Cucumber将退出状态为1(这提醒他们,自从他们通过后他们不再正在进行中)。
@billing
Feature: Verify billing
@important
Scenario: Missing product description
Scenario: Several products
cucumber --tags @billing # Runs both scenarios
cucumber --tags @important # Runs the first scenario
cucumber --tags ~@important # Runs the second scenario (Scenarios without @important)
答案 1 :(得分:12)
根据Cucumber.io, 2种样式可以定义标记表达式。对于您的特定情况,要排除标有@ignore的步骤或功能,这两种样式将转换为:
RewriteEngine On
RewriteRule ^portal/?(.*)$ http://255.255.255.255/$1 [P]
cucumber --tags ~@ignore
。令我惊讶的是,使用在Node.js v6.9.2上运行的相同的cucumber-js v1.3.1,我发现Windows版本只接受新样式,而Linux版本只接受旧样式。根据您的设置,您可能希望同时尝试两者,看看他们是否成功了。
答案 2 :(得分:10)
*。特征
@skip_scenario
Scenario: Hey i am a scenario
Given blah blah
And blah blah blah
CucumberHooks.java
package CucumberHooks;
import cucumber.api.Scenario;
import cucumber.api.java.Before;
public class CucumberHooks {
@Before("@skip_scenario")
public void skip_scenario(Scenario scenario){
System.out.println("SKIP SCENARIO: " + scenario.getName());
Assume.assumeTrue(false);
}
}
答案 3 :(得分:3)
@ActivateSegment
Feature: Test for Activate segment
Scenario: Login
Given I navigate to M
And I enter user name
And I enter password
And I login to MM
Scenario: Open grid
Given I choose menu
And I choose Segments menu
@avoid
Scenario: Open segment creation page
Given I click on New button
And I click on Segment button
黄瓜选项
<\ n>在跑步者班级中,使用您不想要运行的如下所示的标签: tags = {&#34;〜@ avoid&#34;}答案 4 :(得分:3)
我认为特殊标记@wip
已经具有本机支持,并且可以在不添加任何其他代码的情况下使用。
它甚至有一个相关的命令行开关:
-w, --wip Fail if there are any passing scenarios.
答案 5 :(得分:0)
使用JUnit runner class
并参考https://cucumber.io/docs/cucumber/api/#ignoring-a-subset-of-scenarios
您可以创建自己的忽略标记
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(tags = "not @ignore")
public class RunCucumberTest {
}
然后只需标记这种情况:
@ignore
Scenario: Check if all the 3 categories of cats are displayed
Given I open the Cats App
When I view the home screen
Then I should see all three cats categories displayed
答案 6 :(得分:0)
您可以在命令行中编写
mvn test -DCucumber.options =“-标记'@login而不是@grid'”
在外部加上双引号(“”),在内部加上单引号(')
答案 7 :(得分:0)