0

I have a parameterized JUnit 5 test, e.g.

@EnumSource(Mode.class)
@ParameterizedTest void shouldRunWithMode(Mode mode) {
    ...

I want to exclude one of the enum cases from running in Maven, as described here:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.22.2</version>
    <configuration>
        <test>!testpackage.SomeTest#shouldRunWithMode[3 three]</test>
    </configuration>
</plugin>

The same thing without the ! would mean inclusion, i.e. execute only this test.

I played around with the exclude expression and the square brackets, but I didn't find a combination to make it work.

A demo project is on GitHub.

rü-
  • 2,129
  • 17
  • 37
  • First I recommend to upgrade to most recent version of maven-surefire-pugin cause there had been improvements related to JUnit Jupiter platform...cause you are referencing version 2.22.2 but the docs are 3.0.0-M4 ... – khmarbaise Feb 06 '20 at 07:49
  • Thanks for the hint, @khmarbaise. That's a milestone release, but worth giving a try... but it didn't help :-/ – rü- Feb 07 '20 at 08:17
  • Check the syntax cause your example gives the package `testpackage` instead of `pkg/..` furthermore I would check to use `SomeTest.class#shouldRunWithMode`... – khmarbaise Feb 07 '20 at 10:21
  • I only have a `testpackage`, no `pkg`. And adding `.class` didn't help. – rü- Feb 08 '20 at 13:55
  • You are using a dot instead of `/` see the documentation.... – khmarbaise Feb 08 '20 at 14:12
  • @khmarbaise: I can exclude the complete test with `!somepackage.SomeTest#shouldRunWithMode` or `!somepackage/SomeTest#shouldRunWithMode` or `!**/SomeTest#shouldRunWithMode`. But as soon as I add square brackets to only exclude one of the cases, it executes all. Maybe our feedback loop would be faster, if you'd quickly try your suggestions with the demo project I've linked to. I'm sincerely glad you try to help! – rü- Feb 09 '20 at 13:47

1 Answers1

0

I dug into the code and found that there is no code for it. It's obviously supported only on JUnit 4.

I reported it as a bug SUREFIRE-1753

rü-
  • 2,129
  • 17
  • 37