Spring Boot中JUnit 4与JUnit 5的如何共存

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>mygroup</groupId> <artifactId>minimal-conf-junit4-5</artifactId> <version>0.0.1-SNAPSHOT</version> <properties> <!-- JUnit 5 depends on JDK 1.8 --> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> <!-- JUnit dependency versions --> <junit.version>4.12</junit.version> <junit-vintage-engine>4.12.1</junit-vintage-engine> <junit-jupiter.version>5.0.1</junit-jupiter.version> <junit-platform.version>1.0.1</junit-platform.version> </properties> <dependencies> <!--JUnit Jupiter API to write and compile tests with JUnit5 --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-api</artifactId> <version>${junit-jupiter.version}</version> <scope>test</scope> </dependency> <!-- JUnit 4 to make legacy JUnit 4 tests compile --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>${junit.version}</version> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.19.1</version> <!-- matters until now--> <dependencies> <!-- to let surefire to run JUnit 4 but also JUnit 5 tests --> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-surefire-provider</artifactId> <version>${junit-platform.version}</version> </dependency> <!-- JUnit vintage engine to run JUnit 3 or JUnit 4 tests --> <dependency> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> <version>${junit-vintage-engine}</version> </dependency> <!-- JUnit 5 engine to run JUnit 5 tests --> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>${junit-jupiter.version}</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
上一篇:Webfunny前端监控如何接入飞书单点登录(SSO)


下一篇:RabbitMQ传递序列化/反序列化自定义对象时踩坑-问题