0

I have 2 pom.xml-

one is for testing and the second is for running jetty with war deployment.

How can I run surefire tests on the second pom, when I'm running the first pom?

I tried to call it as a profile in the first pom and the surefire plugin is

started but it doesn't run my tests.

12:01:24 [INFO] --- maven-surefire-plugin:2.16:test (integration-test) @ apm-tests ---
12:01:32 [INFO] No tests to run.

pom structure:

<parent>
        <artifactId>apm-root</artifactId>
        <groupId>com.platform</groupId>
        <version>12.50.9999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>apm-tests</artifactId>

<packaging>pom</packaging>

<dependencies>
    <dependency>
    </dependency>
</dependencies> 


<profile>
    <id>generate-schema</id>
    <build>
         <plugins>
            <plugin>
            </plugin>
        </plugins>
    </build>
</profile>

<profile>
    <id>start-jetty</id>
    <build>
        <plugins>
            <plugin>
            </plugin>
        </plugins>
    </build>
</profile>

<profile>
    <id>tests</id>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${surefire.version}</version>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <phase>integration-test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration> 
                            <skipTests>false</skipTests>
                            <argLine>-Xmx1536m</argLine>
                            <testSourceDirectory>path_to_tests(2nd pom)</testSourceDirectory>
                            <includes>
                                <include>path_to_tests/**/*.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>
Pistachio
  • 1,652
  • 1
  • 18
  • 38
Shahar Hamuzim Rajuan
  • 5,610
  • 9
  • 53
  • 91
  • Show pom and structure? – question_maven_com Nov 25 '15 at 13:35
  • I edit the question, is that more understandable now? – Shahar Hamuzim Rajuan Nov 25 '15 at 13:57
  • it's not very clean to depend a pom1 to pom2. each module must be independent . ask your problem with more detail and see what is the right solution but in my opinion your proposal to wait for a pom1 exectue a test and pom2 do something is not clean.. – question_maven_com Nov 26 '15 at 13:59
  • @question_maven_com I understand that, But think about it differently: First pom will just need to deploy an application and the second one will run the tests on that app. In addition I am using jenkins for my CI. the problem is that I need to use different settings.xml file for the test. so I'll have to use a different maven build instead of working with the phases. – Shahar Hamuzim Rajuan Nov 26 '15 at 14:05
  • It s true : parent pom : +apm-tests +pom2 apm-tests (pom1) execute goal 'test' at phase 'integration-test' and use testSourceDirectory from 'pom2'. give pseudo code ? – question_maven_com Nov 26 '15 at 14:14
  • @question_maven_com I wrote this question a bit more detailed here, If you can have a look. http://stackoverflow.com/questions/33977452/how-to-ignore-maven-profiles-in-child-module – Shahar Hamuzim Rajuan Nov 29 '15 at 08:20

0 Answers0