[英]Is JUnit Engine required for your test suite to run?
测试套件是否需要junit-jupiter-engine
作为依赖项,还是junit-jupiter-api
就足够了?
在 Stack Overflow - Difference between junit-jupiter-api and junit-jupiter-engine 的一篇文章中,我发现这两个依赖项对于我们的测试套件的运行都是必不可少的。 但是,执行以下简单测试套件可以在没有以前的依赖关系的情况下工作。
@Test
void testNull() {
assertThatThrownBy(() -> {
strategy.sort(null);
}).isInstanceOf(NullPointerException.class);
}
@Test
void testEmptyArray() {
int[] arr = new int[0];
strategy.sort(arr);
assertThat(arr).isEmpty();
}
@Test
void testUniqueEntries() {
int[] arr = {1, 2, 14, 3, 45, 7, 24, 13};
int[] expected = {1, 2, 3, 7, 13, 14, 24, 45};
strategy.sort(arr);
assertThat(arr).isEqualTo(expected);
}
@Test
void testDuplicationEntries() {
int[] arr = {1, 5, 3, 7, 4, 3, 8, 2};
int[] expected = {1, 2, 3, 3, 4, 5, 7, 8};
strategy.sort(arr);
assertThat(arr).isEqualTo(expected);
}
我想我还不能说出引擎和 API 之间的具体区别,所以我希望能对这个话题发表任何评论。 (现实世界的类比会很有帮助。)
是的,您需要junit-jupiter-engine
依赖项来在构建期间触发测试。
API 只是帮助您编写 junit 测试的工具,引擎运行测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.