Spring Boot 中使用 JUnit

2019-05-15  本文已影响0人  cjlynn

加入依赖

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-test</artifactId>

    <scope>test</scope>

</dependency>

Spring Boot 测试

// 注意此测试类一定要在@SpringBootApplication注解类的包下

@SpringBootTest

// 让 JUnit 运行 Spring 的测试环境, 获得 Spring 环境的上下文的支持

@RunWith(SpringRunner.class)

public class AdminApplicationTests {

    @Test

public ...

}

上一篇下一篇

猜你喜欢

热点阅读