How to run tests after deployment using Maven?

后端 未结 2 1506
余生分开走
余生分开走 2021-02-09 17:10

I\'m trying to decide how to create a set of Acceptance Tests for a Java-EE web application.

Here\'s the setup: Maven is used to generate a WAR file and deploy it into

2条回答
  •  生来不讨喜
    2021-02-09 17:38

    Just because that phase is called deploy doesn't mean that you have to use it for deploying your application for testing. In fact, it should only be used for "deploying" the artifact to a maven repository. Read through the description of the Maven lifecycle phases and you'll see that there are some phases dedicated to your use case:

    pre-integration-test
    integration-test
    post-integration-test  
    

    Have a look at the Cargo Maven plugin. It's made to deploy your WAR file to various containers for testing. They definitely show demos of use cases like the one you describe on your site. I would expect that ultimately, you can be using Cargo to deploy to your container ( from one of the earlier phases like pre-integration-test )

    Note, Jenkins also has a plugin that is a wrapper around the Cargo plugin. So you might do what you need via Jenkins. Also note, you don't need to run your Jenkins build job as mvn clean deploy. You could have one build job that just runs the integration tests, and fires another "deploy" job only when it succeeds.

提交回复
热议问题