1、使用
1)配置
修改启动类所在的pom.xml增加单元测试,版本号注意与项目保持一致
java
<!--单元测试配置开始-->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--单元测试配置结束-->
2)写单元测试
单元测试的包名与启动类的要一致
3)websocket处理
java
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
2、常见错误
1)、java.lang.IllegalStateException Unable to find a @SpringBootConfiguration代码报错
https://blog.csdn.net/siaok/article/details/131421575
https://blog.csdn.net/qq_33732195/article/details/128172428
Command line is toolong
https://blog.csdn.net/weixin_42222436/article/details/126343482
2)java.lang.IllegalStateException: Failed to load ApplicationContext
https://blog.csdn.net/int_1021099885/article/details/136871623
websocket整合场景建议参看