控制台显示跳过零个测试

Console shows zero tests skipped

我正在尝试学习在 TestNG 中跳过测试方法的概念。这可以通过 enabled=false 或在 testng.xml 中指定排除标记下的方法名称。但是,当我执行 xml 文件时,控制台报告显示 0 次跳过。实际上跳过了测试方法,但控制台报告显示 0 次跳过。 我在那里错过了什么吗?为什么控制台显示 0 次跳过?

TestNG 中跳过测试的概念不是很透明。来自文档:

If a method depended upon fails and you have a hard dependency on it (alwaysRun=false, which is the default), the methods that depend on it are not marked as FAIL but as SKIP. Skipped methods will be reported as such in the final report (in a color that is neither red nor green in HTML), which is important since skipped methods are not necessarily failures.

因此禁用的测试不被视为跳过。跳过的测试是启用的测试,对 运行 没有意义,因为它们的依赖项失败了。