Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't exclude tags with Maven Surefire via command line options #1612

Closed
hmartinh opened this issue Oct 2, 2018 · 9 comments
Closed

Can't exclude tags with Maven Surefire via command line options #1612

hmartinh opened this issue Oct 2, 2018 · 9 comments

Comments

@hmartinh
Copy link

hmartinh commented Oct 2, 2018

I'm trying to exclude a tag from test execution with Java system props that are passed via the command line, but it's not working.

public class A {

    @Test
    @Tag("NotThreadSafe")
    public void test(){
        System.out.println("NotThreadSafe");
    }

    @Test
    public void test2(){
        System.out.println("It's ok");
    }
}

$: mvn clean test -Dtest="**/selftest/**" -DexcludeTags="NotThreadSafe"

Output:

NotThreadSafe
It's ok

But -Dgroups propery works fine:

$: mvn clean test -Dtest="**/cdp/autotests/selftest/**" -Dgroups="NotThreadSafe"

Output:

NotThreadSafe
@sormuras
Copy link
Member

sormuras commented Oct 2, 2018

Assuming you're using Surefire 2.22.0, you may exclude tags via excludedGroups.

For details see https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html

@hmartinh
Copy link
Author

hmartinh commented Oct 2, 2018

Assuming you're using Surefire 2.22.0, you may exclude tags via excludedGroups.

For details see https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit-platform.html

Yeah, but in this case i have to make two profiles with different exclude/include Tags :(

@sormuras
Copy link
Member

sormuras commented Oct 2, 2018

That's how Maven/Surefire works. Perhaps StackOverflow is a better place to ask Surefire configuration/setup related questions. Their might be a solution to your task. :)

@sbrannen sbrannen changed the title Can't pass properties throw command line options Can't exclude tags with Maven Surefire via command line options Oct 2, 2018
@sbrannen
Copy link
Member

sbrannen commented Oct 2, 2018

Yeah, but in this case i have to make two profiles with different exclude/include Tags :(

Have you tried using a tag expression instead of just simple tags?

@sbrannen
Copy link
Member

sbrannen commented Oct 2, 2018

Closing this issue since the JUnit team no longer maintains the Maven Surefire provider.

@sbrannen sbrannen closed this as completed Oct 2, 2018
@hmartinh
Copy link
Author

hmartinh commented Oct 2, 2018

Yeah, but in this case i have to make two profiles with different exclude/include Tags :(

Have you tried using a tag expression instead of just simple tags?

Yep, it's solution, thnx
mvn clean test -Dtest="/selftest/" -Dgroups=!NotThreadSafe

@sbrannen
Copy link
Member

sbrannen commented Oct 2, 2018

You're welcome.

Glad that works for you!

And thanks for letting us know.

@Ghilteras
Copy link

I have the same issue and just specifying -Dgroups should work, according to the documentation, but it does not, not sure why you need to specify -Dtest here

@GuptaMegha
Copy link

Putting in single quotes works for me:
mvn clean test '-Dgroups=!category'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants