Search This Blog

Saturday 4 February 2017

How to separate normal build, unit test and integration test



Ideally integration test should be created in a separate bundle. Hence the below steps should be done on the integration test pom. Ie unhcr.it.tests/pom.xml.
Ideally during the build, integration test should not be executed but unit test can be executed.

Steps to exclude integration tests by default.
1.      Exclude integration test from maven-surefire-plugin plugin(plugin for unit tests)
                    <excludes>
                        <exclude>**/*ITTest.java</exclude>
                    </excludes>
</configuration>

2.      In maven-failsafe-plugin include IT test.

<configuration>
                    <skipITs>true</skipITs>
                    <includes>
                        <include>**/*ITTest.java</include>
                    </includes>
</ configuration>

3.      Add <skipITs>true</skipITs> as above.

4.     This will allow you to run with tests disabled by default and to run them with this command:
mvn install -DskipITs=false

Similarly <skipTests>true</skipTests> can be used for skipping both unit and integration tests. Since skipTests is also supported by the Surefire Plugin, this will have the effect of not running any tests. If, instead, you want to skip only the integration tests being run by the Failsafe Plugin, you would use the skipITs property instead as already shown above.


No comments:

Post a Comment