Maven FailSafe插件的好处 [英] Benefits of Maven FailSafe Plugin
问题描述
我阅读了 Maven故障安全插件是专门为运行集成测试而设计的.目前,我正在从事一个多模块项目,集成测试在其自己的单独模块中,用TestNg编写,并使用
I read Maven Failsafe plugin is designed specifically to run integration tests. Currently I'm working on a multi-module project and integration tests are in its own separate module, written in TestNg and run using Surefire plugin. We don't have conflicts with unit tests since only integration tests are run in the test phase in that module. And to set up the environment before the tests, and clean it after tests are run, @BeforeSuite @AfterSuite
TestNg annotations are used. So there's no need to make use of pre-integration-test
phase, integration-test
phase, post-integration-test
phase utilized by Failsafe plugin.
- 通过不使用Failsafe插件,我还能缺少更多的好处吗?
- 是否有使用Failsafe插件满足我当前要求的更好方法?
- 是否可以在
pre-integration-test
,post-integration-test
阶段执行服务器启动,关闭,文件解压缩等操作,而无需编写Maven插件?
- Are there any more benefits I'm missing out on, by not using the Failsafe plugin?
- Are there better ways to do my current requirement using Failsafe plugin?
- Can I do my server startup, shut down, file unzipping etc. in the
pre-integration-test
,post-integration-test
phases without writing a maven plugin?
推荐答案
如果您已经在套件中拥有自己的测试设置/拆卸功能,那么从外观上看,从FailSafe中获益不多插入.
If you already have your own test setup/teardown in your suites, which from the looks of it you do, there is not much you can gain from the FailSafe plugin.
FailSafe插件在被测系统的安装成本很高或需要很长时间(例如启动Servlet或分布式系统)的情况下很有用.在这些情况下,FailSafe插件方便使用的方法是可以在pre-integration-test
阶段中设置此环境.当测试失败时,此插件也不会停止执行Maven构建,这允许您在post-integration-test
阶段清理所有工件,然后检查测试状态并通过或失败构建相应地,在verify
阶段.
The FailSafe plugin is useful in situations where the Setup of your System Under Test is costly or takes a long time such as starting up a Servlet or a distributed system. The way the FailSafe plugin comes handy in these situations is that you can set up this environment in the pre-integration-test
phase. This plugin also doesn't stop the execution of the Maven build when a test fails, which allows you to clean up all of your artifacts during the post-integration-test
phase, after which it checks the status of your tests and passes or fails the build accordingly during the verify
phase.
这篇关于Maven FailSafe插件的好处的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!