春季启动测试启动应用程序

时间:2018-06-21 14:39:28

标签: java spring-boot

我已经编写了简单的Spring boot命令行应用程序。我正在执行单元测试,但我发现该应用程序也正在运行。如何停止?

主应用

@SpringBootApplication
public class Application {
  @Bean
  public CommandLineRunner demo(TransactionLogRepository repository) {
    return (args) -> {
        log.info("Application starts");

测试

@RunWith(SpringRunner.class)
@SpringBootTest
public class ApplicationTests {

  @Autowired
  private ComputeBrand normalizer;

  @Test
  public void test() {
    log.info("Test starts");

日志

16:27:12.791 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class ApplicationTests]
2018-06-21 16:27:14.874  INFO 40980 --- [           main] .v.c.ApplicationTests : Starting ApplicationTests on DSCX516258 with PID 40980 (started by leos.literak
2018-06-21 16:27:14.877  INFO 40980 --- [           main] .v.c.ApplicationTests : No active profile set, falling back to default profiles: default
2018-06-21 16:27:14.939  INFO 40980 --- [           main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@13f17eb4: startup date [Thu Jun 21 16:27:14 CEST 2018]; root of context hierarchy
2018-06-21 16:27:22.485  INFO 40980 --- [           main] .v.c.ApplicationTests : Started ApplicationTests in 8.45 seconds (JVM running for 11.151)
2018-06-21 16:27:22.513  INFO 40980 --- [           main] c.a.p.v..Application  : Application starts
2018-06-21 16:27:23.373  INFO 40980 --- [           main] c.a.p.v.c.ApplicationTests : Test starts

问题出在哪里?

1 个答案:

答案 0 :(得分:0)

我创建了以下解决方法:

application.properties

this.map.markers.user.on("moveend", (e) => {
    this.showSubmit(e);
}); 

应用程序

 unitTest=false