国内知名
计算机技术平台

Spring Boot 2.2.X单元测试配置

配置

pom方式

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.5.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
    </exclusions>
</dependency>

gradle方式

plugins {
    id 'org.springframework.boot' version '2.2.5.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
}
testImplementation('org.springframework.boot:spring-boot-starter-test') {
    exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}

使用

一定要在test包下使用,因为配置的testImplementation

@SpringBootTest
class EimsApplicationTests {
    @Test
    void contextLoads() {
    }
}

注:以上配置使用IDEA创建项目时会自动配好,无需手动配置

赞(0) 打赏
未经允许不得转载:东云网 » Spring Boot 2.2.X单元测试配置
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

东云IT,与您偕行!

免责声明联系我们

觉得文章有用就打赏一下文章作者吧,么么哒~

非常感谢你的打赏,我们将继续给力更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫打赏

微信扫一扫打赏