mercredi 16 octobre 2019

Splitting unit and integration tests with Maven

I'm setting up a CD pipeline in Jenkins and I want to run my unit tests and integration tests in two different steps. The plan is to have my pipeline script look something like this and have them run separately:

    stage('Unit tests') {
        steps {
            withMaven(maven: 'Maven 3.6.2') {
                sh 'mvn test -P coverage'
            }
        }
    }
    stage('Integration tests') {
        steps {
            withMaven(maven: 'Maven 3.6.2') {
                sh 'mvn test -P coverage'
            }
        }

I have tried using the surefire plugin as described here: https://dzone.com/articles/splitting-unit-and-integration-tests-using-maven-a, and running 'mvn test' does run only the unit test as it should, but 'mvn integration-test' runs both unit and integration tests.

I have also tried using the failsafe plugin as described here: Maven separate Unit Test and Integration Tests, but 'mvn verify' runs both unit and integration tests no matter which options I enter.

How can I make my pipeline execute the unit tests and integration tests in two different steps?

Aucun commentaire:

Enregistrer un commentaire