import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MyApplication.class)//MyApplication.class就是SpringBoot项目的启动类
public class MyBootTest {
@Autowired
private UserService userService;
@Test
public void test1(){
userService.xxx();
}
}
idea右键’Run test1()’