Spring boot 为什么@SpringBootTest运行@SpringBootApplication并跳过@Test方法?

Spring boot 为什么@SpringBootTest运行@SpringBootApplication并跳过@Test方法?,spring-boot,spring-boot-test,Spring Boot,Spring Boot Test,我按照本文中的步骤7为SpringBoot命令行应用程序创建了一个集成测试: 这是我的集成测试 @RunWith(SpringRunner.class) @SpringBootTest @TestPropertySource(locations = "classpath:application.integrationtest.properties") public class IntegrationTest { @Autowired private RequestProcess

我按照本文中的步骤7为SpringBoot命令行应用程序创建了一个集成测试:

这是我的集成测试

@RunWith(SpringRunner.class)
@SpringBootTest
@TestPropertySource(locations = "classpath:application.integrationtest.properties")
public class IntegrationTest {

    @Autowired
    private RequestProcessor requestProcessor;


    @Test
    public void testRequestProcessor() {
        requestProcessor.setStandloneFlag(true);
        requestProcessor.processRequest();

    }
}
当我运行这个测试时,它会启动@SpringBootApplication本身,但在集成测试中不会运行@test方法。政府说这不应该发生


为什么@SpringBootTest会忽略我的@Test方法并启动应用程序?

那么您的代码中一定有某种东西阻止调用它。另外,您现在如何处理忽略了
@Test
方法的问题?(您是否使用了正确的
@Test
注释?)。我知道在那里和SpringBootApplication类的run()方法中设置断点会忽略它。调试器在run()方法中中断,但从不在@Test方法中中断。我使用的是junit 4.12中的org.junit.Test注释。它是否真的在不运行测试的情况下完成,或者整个过程都在等待?它从不运行测试。应用程序本身是连续运行的,因此如果SpringBootTest正在等待应用程序终止,则永远不会发生这种情况。有一个参数告诉应用程序在处理完所有可用文件后终止。我在测试方法中设置了该参数,但在运行应用程序本身时没有设置。启动应用程序时是否执行了一些阻塞操作?这可能会因为主线程太忙而阻止实际测试的执行。那么代码中一定有什么东西阻止调用它。另外,您现在如何处理忽略了
@Test
方法的问题?(您是否使用了正确的
@Test
注释?)。我知道在那里和SpringBootApplication类的run()方法中设置断点会忽略它。调试器在run()方法中中断,但从不在@Test方法中中断。我使用的是junit 4.12中的org.junit.Test注释。它是否真的在不运行测试的情况下完成,或者整个过程都在等待?它从不运行测试。应用程序本身是连续运行的,因此如果SpringBootTest正在等待应用程序终止,则永远不会发生这种情况。有一个参数告诉应用程序在处理完所有可用文件后终止。我在测试方法中设置了该参数,但在运行应用程序本身时没有设置。启动应用程序时是否执行了一些阻塞操作?这可能会由于主线程太忙而阻止执行实际测试。