gpt4 book ai didi

java - 如何在 spring-boot 1.5.10 中升级 JUnit-5?

转载 作者:行者123 更新时间:2023-11-30 10:09:04 25 4
gpt4 key购买 nike

我正在使用 spring-boot-1.5.10.RELEASE 并使用 spring-boot-starter-test 用于内置 JUnit-1.4 的单元测试。我想在我的项目中使用 JUnit-1.5。我在互联网上浏览了大部分指向 spring-boot-2.0 的搜索结果链接。 我们不能将 JUnit-5 与 sprint-boot-1.5.X 一起使用吗?

GitHub 链接或提示非常有用。

最佳答案

要迁移,您可以查看此链接 https://www.baeldung.com/junit-5-migration使用 Junit 5 的依赖项,https://www.petrikainulainen.net/programming/testing/junit-5-tutorial-running-unit-tests-with-maven/如果你想使用 spring boot starter 测试,应该排除与 Junit 5 相关的依赖项

 <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>1.5.1.RELEASE</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- declare the exclusion here -->
<groupId>sample.junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>

并根据 Junit 5 版本添加它们,或者您可以声明版本

 <properties>
<junit-jupiter-engine.version>5.1.0</junit-jupiter-engine.version>
<junit-vintage-engine.version>5.1.0</junit-vintage-engine.version>
<junit-platform-launcher.version>1.1.0</junit-platform-launcher.version>
<junit-platform-runner.version>1.1.0</junit-platform-runner.version>
</properties>

关于java - 如何在 spring-boot 1.5.10 中升级 JUnit-5?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53472729/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com