所需JDK
Junit 4 | Junit 5 |
---|---|
需要 Java 5 或以上版本 | 需要Java 8 或以上版本 |
Architecture
Junit 4 所有的东西在一个jar包里,maven依赖如下:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
Junit 5 由JUnit Platform, JUnit Jupiter 和 JUnit Vintage 三个子项目组成:
- JUnit Platform
定义了 test engine API,用于开发在平台上运行新测试框架 - JUnit Jupiter:包含所有注解,有 TestEngine 实现来运行用这些注解编写的测试用例。
- JUnit Vintage
用JUnit 3 和 JUnit 4写的测试用例可以在JUnit 5 Platform上运行
注解
说明 | Junit 4 | Junit 5 |
---|---|---|
定义测试方法即用例 | @Test | @Test |