按照开发阶段化划分
项目测试顺序:
单元测试——功能测试——自动化测试,性能测试
一、单元测试
构成小单元进行测试
安装Junit 插件:
添加 junitGenerator:
链接:https://pan.baidu.com/s/18Z8cFbCmvrSo6nungq5sPQ
提取码:2j7t
添加依赖:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
找到 ImageDao 类,使用快捷键 Ctrl+Shift+T:
添加的单元测试在 test/dao/ImageDaoTest 中:
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.*;
public class ImageDaoTest {
@Before
public void before(){
System.out.println("--------before--------");
}
@After
public void after(){
System.out.println("--------after--------");
}
@Ignore
@Test
public void insert() {
Image image=new Image();
image.setImageName("1.png");
image.setSize(100);
image.setUploadTime("20200808");
image.<