问题描述
我有一个多模块项目spring boot项目,其中每个模块都产生一个jar.每个模块都有一个带有junit 5测试的src/main/test
.在特定模块中的src/main/test
中的所有测试执行之前和之后,是否可以运行代码?例如,如果我有2个模块A和B,我想要.
I have a multi module project spring boot project, where each module produces a jar. Each module has a src/main/test
with junit 5 tests. Is there a way to run code before and after all the tests in src/main/test
in a specific module execute? For example if I have 2 modules A, and B I want.
- 在模块A中的所有测试执行之前运行代码
- 运行所有测试模块A执行的代码
- 在模块B中的所有测试执行之前运行代码
- 在模块B中的所有测试执行后运行代码
推荐答案
您可以定义测试类中方法的顺序,但不能定义测试类的顺序.
You can define the order for methods in a test class, but not for order of test classes.
对此功能有一个公开的请求,但是尚无消息说JUnit将实现它: https://github.com/junit-team/junit5/issues/1948
There is an open request for this feature, but there's no word yet if JUnit will implement it: https://github.com/junit-team/junit5/issues/1948
这篇关于如何在模块中执行所有junit5测试之前和之后编写一次代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!