0
votes

I'm trying to use the Maven plugin Failsafe to run my integration tests that are in the src/it/java directory. I was using the build-helper plugin to get my integration test resources

I setup my failsafe plugin like...

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

                    <configuration>
                        <printSummary>true</printSummary>
                    </configuration>
                </plugin>

With my build-helper plugin setup like...

              <plugin>                                                             
                    <groupId>org.codehaus.mojo</groupId>                             
                    <artifactId>build-helper-maven-plugin</artifactId>               
                    <executions>                                                     
                        <execution>                                                  
                            <id>add-source</id>                                      
                            <phase>generate-sources</phase>                          
                            <goals>                                                  
                                <goal>add-test-source</goal>                         
                            </goals>                                                 
                            <configuration>                                          
                                <sources>                                            
                                    <source>
                                        <directory>src/it/java</directory>
                                    </source>                     
                                </sources>                                           
                            </configuration>                                         
                        </execution>                                                 
                        <execution>                                                  
                            <id>add-resource</id>                                    
                            <phase>generate-sources</phase>                          
                            <goals>                                                  
                                <goal>add-test-resource</goal>                       
                            </goals>                                                 
                            <configuration>                                          
                                <resources>                                          
                                    <resource>                                       
                                        <directory>src/it/resources</directory>      
                                    </resource>                                      
                                </resources>                                         
                            </configuration>                                         
                        </execution>                                                 
                    </executions>                                                    
                </plugin>

I also have Surefire plugin to run my unit tests...

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
        </plugin>

When I do mvn clean verify, only the unit tests run with surefire and failsafe doesn't run, when I try mvn failsafe:verify no tests run, when I try mvn build-helper:add-test-sources failsafe:verify, it throws an error that it cannot find the test sources.

[ERROR] Failed to execute goal org.codehaus.mojo:build-helper-maven-plugin:3.0.0:add-test-source (default-cli) on project stkweb: The parameters 'sources' for goal org.codehaus.mojo:build-helper-maven-plugin:3.0.0:add-test-source are missing or invalid -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException

Right now if I change the configuration around with surefire slightly and put my integration tests in the src/test/java folder, it can run them fine. Just we want them in a separate directory for design reasons.

1

1 Answers

0
votes

The issue came down to using the <pluginManagement> tag.

<build>
  <pluginManagement>
    <plugins>
    </plugins>
  </pluginManagement>
</build>

When I removed the pluginManagement tag, it started running FailSafe.

<build>
  <plugins>
  </plugins>
</build>

This also fixed an issue we had with Jacoco as well, before we just had to call Jacoco directly.