Michal
Michal

Reputation: 750

Maven failsafe plugin does not execute tests

I have a problem with Maven Failsafe plugin that does not execute my tests. The test is stored in folder \src\test\java\ and its name is Test1IT.java which is in the correct format. In addition I have to exclude this test in Maven compiler plugin,because this test is dependent on jetty run. Here is the pom.xml

<plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
            <executions>
                <execution>
                    <id>default-testCompile</id>
                    <phase>test-compile</phase>
                    <configuration>
                        <testExcludes>
                            <exclude>**/*.java</exclude>
                        </testExcludes>
                    </configuration> 
                    <goals>
                        <goal>testCompile</goal>
                    </goals>
                </execution>                  
            </executions>
</plugin>

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19</version>
            <executions>
                <execution>
                    <id>integration-test</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
                <execution>
                    <id>verify</id>
                    <goals>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

If executed mvn verify it builds everything, start jetty and return

[INFO] --- maven-failsafe-plugin:2.19:integration-test (integration-test) @ application ---
[INFO] No tests to run.

What is the problem?

Upvotes: 2

Views: 1777

Answers (1)

Michal
Michal

Reputation: 750

Actually after several hours of experimenting with Maven I was able to find working version:

Here is the pom.xml file

<plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.3</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
</plugin>

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.19</version>
            <executions>
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

<plugin>

            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.2.v20140723</version>      
            <configuration>
                <scanIntervalSeconds>10</scanIntervalSeconds>
                <stopPort>9966</stopPort>
                <stopKey>abc</stopKey>
                <webApp>
                    <contextPath>/hellojavaworld</contextPath>           
                </webApp>    
            </configuration>
            <executions>
                <execution>
                    <id>start-jetty</id>
                    <phase>pre-integration-test</phase>
                    <goals>
                        <goal>run-war</goal>
                    </goals>
                    <configuration>
                        <daemon>true</daemon>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                    </configuration>
                </execution>
                <execution>
                    <id>stop-jetty</id>
                    <phase>post-integration-test</phase>
                    <goals>
                        <goal>stop</goal>
                    </goals>
                </execution>
            </executions>
</plugin>

Be careful about used version for maven jetty plugin. For my particular scenario the latest working version is 9.2.2.v20140723. Any newer version have malfunction. It just starts jetty and script does not continue further. I am not sure if this is a bug, but it should not happen.

Hope this post helps.

Upvotes: 1

Related Questions