How to run individual test in the integration-test target in maven

integration-testingmaven-2maven-surefire-plugin

We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish.

What I want to do is run just one test in the integration-test. I tried doing :

mvn -Dtest=<my-test> integration-test

but that does not work. The -Dtest runs only the tests in the unit test goal, not the integration-test phase. I tried the -Dintegration-test=<my-test> instead, and that was ignored.

Is there a way to do that ?


My configuration is:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <executions> 
        <execution> 
            <id>surefire-it</id> 
            <phase>integration-test</phase> 
            <goals> 
                <goal>test</goal> 
            </goals> 
            <configuration> 
                <excludes> 
                    <exclude>none</exclude> 
                </excludes> 
                <includes>
                    <include>**/api/**</include> 
                </includes> 
    ..... 

Best Answer

If you're using the Maven failsafe plugin, you can run a single integration test by setting the it.test property to your fully qualified test class name:

mvn -Dit.test=your.TestCase verify

See the failsafe plugin docs for more info.

Related Topic