How to execute scripts before and after SureFire test phase

别来无恙 提交于 2019-12-13 03:15:13

问题


When I invoke mvm test, I want to execute a setup.sql script before Surefire JUnit is invoked and then execute a teardown.sql script after.

I know from questions like this how to execute scripts during the test phase, but I have no idea how to define this specific sequence of events. Thank you!


回答1:


Not with the surefire plugin but with its sibling the failsafe plugin. They both execute Tests but in different life-cycle phases. The surefire plugin in test and the failsafe plugin in integration-test. See life-cycle phases and the default plugin bindings.

The advantage of the failsafe plugin running in the integration test phase is that there are pre- and post- phases.

Since you mention some sql script it seems you want to prepare a database. At that point you are not really doing unit testing anymore but writing an integration test. So using the failsafe plugin makes the most sense here.



来源:https://stackoverflow.com/questions/51527584/how-to-execute-scripts-before-and-after-surefire-test-phase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!