我创建了多个spring-boot测试类,(spring-boot 1.4.0).
FirstActionTest.java:
@RunWith(SpringRunner.class)
@WebMvcTest(FirstAction.class)
@TestPropertySource("classpath:test-application.properties")
public class FirstActionTest {
@Autowired
private MockMvc mvc;
// ...
}
Run Code Online (Sandbox Code Playgroud)
SecondActionTest.java:
@RunWith(SpringRunner.class)
@WebMvcTest(SecondAction.class)
@TestPropertySource("classpath:test-application.properties")
public class SecondActionTest {
@Autowired
private MockMvc mvc;
// ...
}
Run Code Online (Sandbox Code Playgroud)
运行测试时:
mvn测试
它似乎为每个测试类创建了一个弹簧测试上下文,我猜这是不必要的.
问题是: