聊聊springboot2.2.3升级到2.4.0单元测试的区别
目录
- springboot2.2.3升级到2.4.0单元测试区别
- springboot2.4降级到boot2.2.x
springboot2.2.3升级到2.4.0单元测试区别
原先单元测试 import org.junit.Test; 然后运行正常,现在运行报错,
import org.junit.Test;
换成
import org.junit.jupiter.api.Test;
后运行正常。
单个单元测试的这样没有问题了,但是我批量执行的还是会报上面的错误
@Suite.SuiteClasses({ //dao层测试类 //service层测试类 CheckConfigServiceTest.class, AfterCheckConfigServiceTest.class, //control层测试类 //WebTestControllerTest.class //util测试类 }) @RunWith(Suite.class) public class BatchTest { }
最后确实没有解决整合测试也称 打包测试的@Suite.SuiteClasses方法,不过找到了别的批量执行单元测试的方法,
在src/test/java 文件夹右键,run as -> junit test 一样可以批量执行!!!
springboot2.4降级到boot2.2.x
最近在做一个springcloud的整合项目,但是springcloud-alibaba的nacos只支持2.2.x版本,而项目开始也没注意,直接用的2.4版本,所以这里记录下降级踩下的坑。
这里直接把boot版本号改成2.2.6然后去启动主启动类会出现
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent>
以下提示:我的spring和我的boot不兼容,我boot版本太低,让我改成2.3或者是2.4
***************************
APPLICATION FAILED TO START
***************************Description:
Your project setup is incompatible with our requirements due to following reasons:
- Spring Boot [2.2.6.RELEASE] is not compatible with this Spring Cloud release train
Action:
Consider applying the following actions:
- Change Spring Boot version to one of the following versions [2.3.x, 2.4.x] .
You can find the latest Spring Boot versions here [https://spring.io/projects/spring-boot#learn].
If you want to learn more about the Spring Cloud Release train compatibility, you can visit this page [https://spring.io/projects/spring-cloud#overview] and check the [Release Trains] section.
If you want to disable this check, just set the property [spring.cloud.compatibility-verifier.enabled=false]Process finished with exit code 1
我这边直接把springcloud版本一起降低改成H版本
<properties> <java.version>1.8</java.version> <spring-cloud.version>Hoxton.SR9</spring-cloud.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-dependencies</artifactId> <version>${spring-cloud.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
再次启动,发现可以了,好了不多bb了,我要去改接下去其他模块了
以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。