简体   繁体   English

Selenium Webdriver中的Junit标记不起作用

[英]Junit Tagging in Selenium webdriver doesn't work

I'm using Selenium Webdriver with cucumber, gherkin and java. 我正在将Selenium Webdriver与黄瓜,小黄瓜和java一起使用。 I am tagging all my scenario's: @website, @wip, @disabled etc. 我正在标记所有场景:@ website,@ wip,@ disabled等。

When I want to use a junit runner to create certain testsets, it always runs ALL the tests, regardless of what scenario is tagged. 当我想使用junit运行程序创建某些测试集时,无论标记了哪种情况,它始终运行所有测试。

What I got in my junit runner is this: 我在junit跑步器中得到的是这样的:

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 {}

The scenario's and the feature file look somewhat like this: 场景和功能文件如下所示:

# 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

I want my runner to run just scenario 2 and 3 (tagged with @Regression and @Functional respectively), and skip scenario 1 (that's why it's tagged with @wip). 我希望我的跑步者只运行场景2和3(分别标记为@Regression和@Functional),并跳过场景1(这就是为什么使用@wip标记)。 However, when I run the junit runner, it just runs both scenario 1, 2 and any other in any other feature. 但是,当我运行junit Runner时,它将同时运行场景1、2和其他任何功能。

What am I doing wrong here? 我在这里做错了什么?

You are missing a quotes after @Regression, try things mention as below and it should work. 您在@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 {}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM