Maven surefire 和 failsafe 版本总是一样的吗

Are Maven surefire and failsafe versions always going to be the same

我的类路径上同时有 JUnit 和 testng,并且正在使用 Mixing TestNG and JUnit tests in one Maven module – 2013 edition 中的 "provider" 依赖项技巧来选择要使用的一个。

但是,依赖项仅适用于 surefire,因此如果我在故障保护下使用它们,版本号仍将遵循 surefire 的版本号。

这两个测试插件似乎实际上是同一个项目(和相同的代码?)只是名称不同,它们目前具有相同的版本号。在长运行中可能是这种情况吗?

maven-surefire-plugin is intended for unit tests which is bound by default to the test life cycle phase where as the maven-failsafe-plugin is intended for integration tests which is not bound by default to any life cycle phase.

所以他们有很多共同的代码,因为只有细微的差别,但他们并不是偶然地简单地命名不同,而是故意命名不同的。是的,maven-surefire/maven-failsafe 的版本号是同步的,因为它们是 released together。是的,它们将分开存放,因为它们有不同的意图。

如果您不在单个模块中混合使用 junit 和 testng,您可以省略提供程序 trick,只需在适当的模块中使用对 junit 或 testng 的依赖...比 maven-surefire-plugin将自动使用适当的提供程序。