Selenium webdriver中的Junit标记不起作用

时间:2017-02-23 09:55:14

标签: java selenium junit webdriver

我正在使用Selenium Webdriver与黄瓜,小黄瓜和java。我正在标记我的所有场景:@website,@ wip,@ disable等。

当我想使用junit runner来创建某些测试集时,它总是运行所有测试,无论标记的是什么场景。

我在junit runner中得到的是:

package com.website;

import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
    format = "pretty",
    tags = {"@Regression,@Functional","~@wip"},
    features="src/test/resources"
)
public class Runner {}

场景和特征文件看起来有点像这样:

# language: nl

Functionality: This is a feature file

 @wip
 Scenario: stuff-001: As a user, I want stuff
 Given When I do something
 If I click somewhere
 Then I can see something

 @Regression
 Scenario: stuff-002: As a user, I want stuff again
 Given When I do something
 If I click somewhere
 Then I can see something

 @Functional
 Scenario: stuff-003: As a user, I want stuff once more
 Given When I do something
 If I click somewhere
 Then I can see something

我希望我的跑步者只运行场景2和3(分别用@Regression和@Functional标记),并跳过场景1(这就是为什么它用@wip标记)。但是,当我运行junit runner时,它只运行方案1,2和任何其他功能中的任何其他功能。

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

在@Regression之后你错过了一个引号,尝试提到如下,它应该工作。

package com.website;

        import cucumber.api.junit.Cucumber;
        import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        format = "pretty",
        tags = {"@Regression","@Functional","~@wip"},
        features="src/test/resources"
)
public class Runner {}