标签:app 选中 stat autowired ext org ice cto 项目
选中要测试的类, Alt + Enter
出现 create Test
, 选中junit4
要在有启动类的项目中创建
注意这两个注解:
@SpringBootTest(classes = WebApplication.class)
@RunWith(SpringRunner.class)
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;
import static org.junit.Assert.*;
@SpringBootTest(classes = WebApplication.class)
@RunWith(SpringRunner.class)
public class DocumentPoliciesReleaseControllerTest {
@Autowired
private DocumentPoliciesReleaseService service;
@Test
public void delete() {
System.out.println("service = " + service);
}
}
标签:app 选中 stat autowired ext org ice cto 项目
原文地址:https://www.cnblogs.com/wqkeep/p/13202651.html