Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | 51CTO学院 | CSDN程序员研修院 | OSChina 博客 | 腾讯云社区 | 阿里云栖社区 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏多维度架构

第 25 章 Junit5

目录

25.1. 项目初始化
25.1.1. Maven
25.2. JUnit 5 注解
25.2.1. @Disabled
25.2.2. @Tag
25.2.3. @Nested
25.2.4. @TestFactory
25.3. JUnit 5 断言
25.3.1. assertArrayEquals
25.3.2. assertAll
25.3.3.
25.3.4. fail
25.3.5. JUnit 5 前置条件
25.4. 依赖注入
25.4.1. TestInfo
25.4.2. TestReporter
25.5. Junit4
25.5.1. 生成 HTML 报告
25.5.2. Junit4 输出格式定义

JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage

25.1. 项目初始化

25.1.1. Maven

https://github.com/junit-team/junit5-samples/tree/r5.9.0/junit5-jupiter-starter-maven

			
<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>cn.netkiller</groupId>
	<artifactId>inspection</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>inspection</name>
	<url>http://maven.apache.org</url>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<maven.compiler.source>18</maven.compiler.source>
		<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
	</properties>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.junit</groupId>
				<artifactId>junit-bom</artifactId>
				<version>5.9.1</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.8.1</version>
			</plugin>
			<plugin>
				<artifactId>maven-surefire-plugin</artifactId>
				<version>3.0.0-M6</version>
			</plugin>
		</plugins>
	</build>

</project>