首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >弹簧启动测试和弹簧启动测试有什么区别?

弹簧启动测试和弹簧启动测试有什么区别?
EN

Stack Overflow用户
提问于 2020-04-09 09:26:45
回答 3查看 5.1K关注 0票数 16

我正在处理一个项目,我看到定义了这些依赖关系:

代码语言:javascript
复制
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-test</artifactId>
        <scope>test</scope>
    </dependency>
    <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>
            <exclusion>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

但是我不明白为什么使用Spring测试有两个工件,两者之间有什么区别呢?也许与后者,我也是进口前者?

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2020-04-09 09:59:03

spring-boot-starter-test是一个聚合的“初学者包”,用于库,通常用于在Spring应用程序中进行测试。

正如最新版本参考文档中所述,spring-boot-starter-test包含:

  • JUnit 5(包括与JUnit 4向后兼容的老式引擎)
  • Spring & Spring -这是spring-boot-test依赖项)
  • AssertJ,Hamcrest,Mockito,JSONassert和JsonPath。

可以删除spring-boot-test依赖项的显式定义。

票数 16
EN

Stack Overflow用户

发布于 2020-04-09 09:39:18

从Spring官方参考:

Spring在测试应用程序时提供了许多实用程序和注释来帮助您。测试支持由两个模块提供:spring Test包含核心项,以及spring-启动-测试-自动配置支持测试的自动配置。

more details>>

票数 4
EN

Stack Overflow用户

发布于 2020-05-08 07:10:34

请看一下maven定义。包裹的内容在那里很详细。弹簧启动测试似乎是一个超集的春季启动测试,因为春季启动启动测试有依赖于春季启动测试。

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-test/2.2.5.RELEASE

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-test/2.2.5.RELEASE

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61117933

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档