簡體   English   中英

spring-boot-test 與 spring-boot-starter-test 有什么區別?

[英]what's the difference between spring-boot-test vs spring-boot-starter-test?

我正在處理一個項目,我看到定義了這些依賴項:

<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 Boot 測試有 2 個工件,它們有什么區別? 也許對於后者,我也在進口前者?

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官方參考:

Spring Boot 提供了許多實用程序和注釋來幫助測試您的應用程序。 測試支持由兩個模塊提供:spring-boot-test 包含核心項目,spring-boot-test-autoconfigure 支持自動配置測試。

更多詳情>>

請查看 maven 定義。 包的內容在那里有詳細說明。 spring-boot-starter-test 似乎是 spring-boot-test 的超集,因為 spring-boot-starter-test 依賴於 spring-boot-test。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM