<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
/**
* SpringJUnit4ClassRunner.class:Spring运行环境
* JUnit4.class:JUnit运行环境
* SpringRunner.class:Spring Boot运行环境
*/
@RunWith(SpringRunner.class)
//标记为当前类为SpringBoot测试类,加载项目的ApplicationContext上下文环境
@SpringBootTest
class SpringbootDemoApplicationTests {
@Test
void contextLoads() {
}
@Resource
private DemoController demoController;
@Test
public void testDemoController(){
String s = demoController.helloBoot();
System.out.println(s);
}
}
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |