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

后端 未结 3 1712
离开以前
离开以前 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:02

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

    import static org.junit.Assume.assumeTrue;
    
    @Test
    public 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 :)

提交回复
热议问题