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

后端 未结 3 1714
离开以前
离开以前 2021-02-02 14:14

I have a set of really slow tests, which take a week to run. (They literally run some code non-stop for about a week).

Naturally, no developer (or even the default build

3条回答
  •  抹茶落季
    2021-02-02 15:16

    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

    
        org.apache.maven.plugins
        maven-surefire-plugin
        2.12.4
        
            ${tests.exclude}
        
    
    

    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 SlowTest
    public class FastTests {}
    

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

提交回复
热议问题