How to test main class of Spring-boot application

后端 未结 9 1879
心在旅途
心在旅途 2020-12-03 00:18

I have a spring-boot application where my @SpringBootApplication starter class looks like a standard one. So I created many tests for all my functi

9条回答
  •  悲&欢浪女
    2020-12-03 00:52

    
        org.springframework.boot
        spring-boot-maven-plugin
        
            your.awesome.package.Application 
        
    
    

    If you aim for 100% coverage, one thing you can do is simply not having a main method at all. You still require a class annotated with @SpringBootApplication but it can be empty.

    Be warned though as it has its drawbacks and other tools that rely on main can break.

提交回复
热议问题