Hi!

I'm using maven-surefire-plugin 3.0.0-M6 in a multi-module build, with
JUnit 4.13.2. I use JUnit's categories to mark some unit tests as slow
like this:

  @Test
  @Category(SlowTest.class)
  public void someTests() {...}

To avoid running slow tests I run mvn like this:

  mvn test -DexcludedGroups=SlowTest

This works basically. But if I have one module without any tests at all,
surefire fails with the following error:

[ERROR] Failed to execute goal 
org.apache.maven.plugins:maven-surefire-plugin:3.0.0-M6:test (default-test) on 
project my-api-module: groups/excludedGroups require TestNG, JUnit48+ or JUnit 
5 (a specific engine required on classpath) on project test classpath -> [Help 
1]

The error is correct. I do not have any of the mentioned
engines/dependencies on classpath, because I don't need them.

Of course, I could add a dependency to junit, which solves this problem,
but then I have a declared unused dependency, which is ugly.

I also could skip surefire execution by configuring the plugin:

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

This is (IMHO) less ugly as the workaround from above, but this adds a
few lines of configuration which must be remembered to be removed, once
unit-tests are written.

However, I'm still hoping for some clean solution. Any ideas?

Thanks in advance,
- martin

Attachment: pgpuNz4ac3nM2.pgp
Description: Digitale Signatur von OpenPGP

Reply via email to