maven之JUnit5 平台启动器到底是什么

jirigala 阅读:87 2025-06-02 22:19:02 评论:0

JUnit 5 是模块化的。
我了解一切都基于平台模块( junit-platform-engine-1.3.2.jar ):
木星模块(API + 引擎部件:junit-jupiter-engine-5.3.2.jar + junit-jupiter-api-5.3.2.jar)和
复古模块(API + 引擎部件:junit-vintage-engine-5.3.2.jar + junit-4.12.jarhamcrest-core-1.3.jar )都使用平台模块作为基本模块。
但是什么是平台启动器,何时需要?
我何时以及为什么需要它以及如何将其添加到 pom.xml ?

(图片由 link 提供)
将 Jupiter(仅用于 JUnit 5 测试)和 Vintage(用于 Junit4/Junit3 兼容性 - 从 JUnit5 运行旧版 JUnit4 测试)添加到 pom.xml 是这样的(仅供将来引用):

<dependency> 
    <groupId>org.junit.jupiter</groupId> 
    <artifactId>junit-jupiter-engine</artifactId> 
    <version>5.3.2</version> 
    <scope>test</scope> 
</dependency> 
 
<!-- Vintage Module to run JUnit4 from JUnit 5 --> 
<dependency> 
    <groupId>org.junit.vintage</groupId> 
    <artifactId>junit-vintage-engine</artifactId> 
    <version>5.3.2</version> 
    <scope>test</scope> 
</dependency> 

请您参考如下方法:

仅当您想以编程方式启动 JUnit 平台时才需要启动器,即在 IDE、构建工具或控制台运行程序之外。

换句话说:启动器是 IDE 和构建工具使用的 API。


标签:Maven
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

关注我们

一个IT知识分享的公众号