Run integration tests on CI server using maven only

It would make sense to run unit tests of each build, but skip the integration testing step entirely - leave it on the CI server?

I am currently working on a JavaEE project that covers almost only some integration tests that are poorly written and time consuming. Every time I make any changes, I have to wait a few minutes for the build (of which, like 90% of the time, these are those integration tests).

My idea is to set up some CI server for example. Jenkins so that it will take any commit made to the repository (or even better after the maven build) and run the maven build with integration tests. But is it possible to configure maven so that when you type mvn install

it will compile unit tests - build the project but omit the integration phase entirely (to speed up development). Then CI will pick up and run the build again, but this time with integration tests in place?

This way, the time between code change and deployment would be much shorter and less frustrating, and any integration-related errors would be cached for a few minutes after the CI server build is complete.

Is this a good idea? Can anyone suggest how to configure maven to get this behavior?

+3


source to share


2 answers


You should be able to do this using profiles. Although I may need more information about the configuration of your integration tests. I've been doing this with projects for several years using a combination of maven-failafe-plugin and profiles. Here's an example snippet from the pom:

<profiles>
    <profile>
        <id>integration-tests</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>integration-test</id>
                            <goals>
                                <goal>integration-test</goal>
                            </goals>
                            <configuration>
                                ...
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

      



In normal local development, the launch mvn install

should not run integration tests that are run through the maven-failafe-plugin. Then you can configure the CI server to run mvn clean install -Pintegration-tests

.

+4


source


First of all, I think this is a great idea. This will make your development cycle much faster.



I don't know how to completely skip the integration-test phase when you do mvn install. Can you run "mvn clean package" instead during development? If that's not an option, which plugin are you using for your integration test? Most plugins have a "skip" attribute that you can use to skip plugin execution. You can use a profile to turn skip on or off for different scenarios.

+1


source







All Articles