概念
单元测试,又称为模块测试,是针对程序模块(软件设计的最小单位)来进行正确性检验的测试工作。
使用
pom.xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
建立文件
TestOthers
封装了测试前和测试后的方法,以供其他类继承使用
Test
@Test注解进行单元测试
Assert
代码:Assert.assertEquals(expected,actual);
- expected:要测试的内容
- actual:期待值
- 成功
- 失败