Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore a module during maven test build for multi module maven project [duplicate]

Is it possible to run a maven test build (mvn clean test) in a multi module maven project and to skip/ignore a particular module's test? like -Dmaven.test.skip=true but for a particular module and not all the modules? I dont want to change the surefire <configuration> to include <skipTests>true</skipTests> for the module which I want to skip for tests. I wanted to know if this can be done from command line. I need this because in my project I've many modules and particular one or two takes really long to execute test, so when I want to test only couple of modules I'd like to skip these time taking modules to which I've not made any changes.

like image 759
Jay Avatar asked Feb 14 '12 15:02

Jay


1 Answers

Is is really a problem for you to change the configuration of the surefire plugin ? Because you could change it one time only in your module ...

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.12</version>
            <configuration>
                <skipTests>${skip.foo.module.tests}</skipTests>
            </configuration>
        </plugin>
    </plugins>
</build>

... and delegate the true/false value of the skipTests tag to a maven property, activated by a dedicated profile :

<properties>
    <skip.foo.module.tests>false</skip.foo.module.tests>
</properties>

<profiles>
    <profile>
        <id>SKIP_FOO_MODULE_TESTS</id>
        <properties>
            <skip.foo.module.tests>true</skip.foo.module.tests>
        </properties>
    </profile>
</profiles>

So that you could deactivate the tests in Foo module with the command line :

mvn clean test -P SKIP_FOO_MODULE_TESTS

like image 148
Yanflea Avatar answered Sep 29 '22 16:09

Yanflea