Do not run a category of slow JUnit tests by default in Maven and every IDE (Eclipse, IntelliJ, ...) without an explicit TestSuite Do not run a category of slow JUnit tests by default in Maven and every IDE (Eclipse, IntelliJ, ...) without an explicit TestSuite jenkins jenkins

Do not run a category of slow JUnit tests by default in Maven and every IDE (Eclipse, IntelliJ, ...) without an explicit TestSuite


This works by default, in Maven, IntelliJ and Eclipse:

import static org.junit.Assume.assumeTrue;@Testpublic void mySlowTest() {    assumeTrue("true".equals(System.getProperty("runSlowTests")));    ...}

To run them anyway, simply add VM argument -DrunSlowTests=true.

Semantically speaking, it's totally wrong. But it works :)


As far as I know there is no way of preventing Eclipse from running certain tests by default.

Running certain categories from Maven is easy enough using

<plugin>    <groupId>org.apache.maven.plugins</groupId>    <artifactId>maven-surefire-plugin</artifactId>    <version>2.12.4</version>    <configuration>        <excludedGroups>${tests.exclude}</excludedGroups>    </configuration></plugin>

And then define tests.exclude in certain maven profiles.

Maintaining test suites in JUnit is indeed too much work with the current version of JUnit as I've written about in a blogpost. I also explain how a library called cpsuite automatically does the Suite administration for you like this:

@RunWith(ClasspathSuite.class) // Loads all unit tests it finds on the classpath@ExcludeBaseTypeFilter(SlowTest.class) // Excludes tests that inherit SlowTestpublic class FastTests {}

However, in both methods, Eclipse by default will still just run all Java files with a @Test annotation in them.


Why not making Integration test out of slow running test. Using the maven-failsafe-plugin which would handle such cases via different naming conventions. For example *IT.java which are Themen long runnin test. Furthermore i would suggest to put the activation into a profilr so everyone can control to run those test or not which should be the default