Starting external process during integration testing in maven

前端 未结 5 724
礼貌的吻别
礼貌的吻别 2021-01-01 05:24

I want completely automated integration testing for a Maven project. The integration tests require that an external (platform-dependent) program is started before running.

5条回答
  •  春和景丽
    2021-01-01 06:04

    You probably want to bind your actual integration tests to the integration-test phase of the maven lifecycle. If you use a plugin that fails safe (like the aptly named failsafe plugin) to do the actual testing, you can then run your phases like this:

    pre-integration-test: start external application (using the exec plugin or one of the other suggestions here)

    integration-test: Run the actual integration tests using the failsafe plugin

    post-integration-test: Shut down the external application and do any other necessary cleanup

    verify: Have the failsafe plugin verify the results of the test and fail the build at this point

    It's fairly straightforward to use the exec plugin, the trick is to get your application started up in the background. You should be careful to make sure that the app is fully up before starting the tests in the next phase. Unfortunately, getting your application up and making sure it's up enough while running in the background is not always a trivial task, and the specifics of how to do that depend on your application. It often involves custom code in the application.

提交回复
热议问题