如何使用Spring正确定义Suite测试?

时间:2017-05-24 14:34:21

标签: spring unit-testing junit4

所以我设置了这样的套件:

@RunWith(Suite.class)
@SuiteClasses({ 
    Foo1Test.class, 
    Foo2Test.class
    })
public class FooTest {

}

我的单元测试是这样的:

@RunWith(SpringRunner.class)
@SpringBootTest
@AutoConfigureMockMvc
public class Foo1Test {

    @Test
    public void test1() throws Exception {/*...*/}
}

一切都很好,除非我用mvn clean install运行我的项目时测试已运行两次。我该如何预防?

1 个答案:

答案 0 :(得分:0)

在此处找到解决方案:Why are JUnit tests run twice from within Eclipse?

我将单元测试重命名为*TestCase,并将套件保留为*Test

相关问题