spring boot -junit单元测试方法示例

package com.example.zs;

import com.example.zs.mapper.UserMapper;
import com.example.zs.pojo.User;
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 = {SpringBoot.class})
public class UserServiceTest {
@Autowired
private UserMapper userMapper; @Test
public void inser() {
User user = new User("name2",);
userMapper.insertUser(user);
}
}
package com.example.zs;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication
public class SpringBoot {
public static void main(String[] args) {
SpringApplication.run(springBoot.class,args);
}
}
上一篇:软件测试第二次作业——Fault,Failure,Error辨析与设计测试用例


下一篇:SQL Server扩展事件的使用ring_buffer target时“丢失”事件的原因分析以及ring_buffer target潜在的问题