简体   繁体   中英

Junit Tagging in Selenium webdriver doesn't work

I'm using Selenium Webdriver with cucumber, gherkin and java. I am tagging all my scenario's: @website, @wip, @disabled etc.

When I want to use a junit runner to create certain testsets, it always runs ALL the tests, regardless of what scenario is tagged.

What I got in my junit runner is this:

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). However, when I run the junit runner, it just runs both scenario 1, 2 and any other in any other feature.

What am I doing wrong here?

You are missing a quotes after @Regression, try things mention as below and it should work.

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 technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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