原文: http://www.cnblogs.com/xubiao/p/7568257.html
package com.test.service;
import com.task.Application;
import com.task.model.po.TaskRecordDo;
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.SpringJUnit4ClassRunner;
/**
* Created by admin on 2017/9/21-11:33.
* Description :
*/
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class)
public class TaskRecordServiceTest {
@Autowired
private TaskRecordService taskRecordService;
@Test
public void insertTest(){
TaskRecordDo taskRecordDo = new TaskRecordDo("8654111110001", "11110001", "adminTask", "UUIDTest", "修改生产服设备ID", "200");
taskRecordService.insertTaskRecord(taskRecordDo);
}
}
*注意 一个简单的测试单元就这样成功了

本文提供了一个使用Spring Boot框架进行单元测试的示例,展示了如何通过SpringJUnit4ClassRunner和@SpringBootTest注解来测试TaskRecordService的服务层方法。
3588

被折叠的 条评论
为什么被折叠?



