单元测试

This commit is contained in:
star 2024-11-05 17:25:56 +08:00
parent ee9539f124
commit 73e242a4a1
4 changed files with 78 additions and 0 deletions

View File

@ -30,6 +30,22 @@
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- 测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>1
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- 防止进入swagger页面报类型转换错误排除3.0.0中的引用手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>

View File

@ -0,0 +1,32 @@
import com.ktg.RuoYiApplication;
import com.ktg.mes.qc.domain.InventoryTask;
import com.ktg.mes.qc.service.InventoryTaskService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RuoYiApplication.class)
public class test {
@Autowired
private InventoryTaskService inventoryTaskService;
@Test
public void saveTest(){
//新建任务对象
InventoryTask inventoryTaskTest = new InventoryTask();
inventoryTaskTest.setWmsInventoryCode("TEST001");
inventoryTaskTest.setUomId("TEST001");
inventoryTaskTest.setName("测试计划");
inventoryTaskTest.setPlanPeriod("");
inventoryTaskTest.setStartTime("2022-01-01");
inventoryTaskTest.setFinishTime("2022-12-31");
inventoryTaskTest.setSuperiorTime("2022-01-01");
inventoryTaskTest.setBelowTime("2022-12-31");
inventoryTaskTest.setProductId("TEST001");
//新增
int i = inventoryTaskService.insertInventoryTask(inventoryTaskTest);
}
}

View File

@ -21,6 +21,21 @@
<artifactId>jasperreports</artifactId>
<version>6.18.1</version>
</dependency>
<!-- 测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports-fonts</artifactId>

15
pom.xml
View File

@ -122,6 +122,21 @@
<version>${commons.fileupload.version}</version>
</dependency>
<!-- 测试 -->
<!-- 测试 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>3.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- excel工具 -->
<dependency>
<groupId>org.apache.poi</groupId>