JUnit5单元测试提示“Not tests were found”错误

JUnit5单元测试提示“Not tests were found”错误,如下图所示:
JUnit5单元测试提示“Not tests were found”错误_第1张图片
或者
JUnit5单元测试提示“Not tests were found”错误_第2张图片
问题解析:
1)使用@Test注解时,不能有返回值;
2)使用@Test注解时,不能使用private关键字;
存在以上情况时执行单元测试,都会提示“Not tests were found”错误,如下图所示:
JUnit5单元测试提示“Not tests were found”错误_第3张图片
正确的示例是使用public void关键字定义方法,如下图所示:
JUnit5单元测试提示“Not tests were found”错误_第4张图片
再次执行单元测试成功了,如下图所示:
JUnit5单元测试提示“Not tests were found”错误_第5张图片

“Test Hello !”信息打印输出成功。

你可能感兴趣的:(Java,单元测试,java,junit)