Running Spock tests with Maven located at src / test / java

I have several Spock tests:

MyTest.groovy
ConfTest.groovy

      

which are Spock's tests. They are located in src/test/java

, and when I run the check, they are skipped. When I put them in src/test/groovy

Maven find them. Can I configure Maven to find them when they are in src/test/java

? My Maven configurations:

 <!-- Groovy compilation -->
            <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.4</version>
                <configuration>
                    <providerSelection>1.8</providerSelection>
                    <source/>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generateStubs</goal>
                            <goal>compile</goal>
                            <goal>compile</goal>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.gmaven.runtime</groupId>
                        <artifactId>gmaven-runtime-1.8</artifactId>
                        <version>1.4</version>
                        <exclusions>
                            <exclusion>
                                <groupId>org.codehaus.groovy</groupId>
                                <artifactId>groovy-all</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <version>1.8.6</version>
                    </dependency>
                    <dependency>
                        <groupId>org.spockframework</groupId>
                        <artifactId>spock-core</artifactId>
                        <version>0.7-groovy-1.8</version>
                        <exclusions>
                            <exclusion>
                                <groupId>org.codehaus.groovy</groupId>
                                <artifactId>groovy-all</artifactId>
                            </exclusion>
                        </exclusions>
                    </dependency>
                </dependencies>
            </plugin>

       <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <useFile>false</useFile>
                <includes>
                    <include>**/*Test.*</include>
                </includes>
            </configuration>
        </plugin>

      

+3


source to share


1 answer


Add this to your GMaven config at the plugin level:

<configuration>
    <testSources>
        <testSource>
                <directory>${pom.basedir}/src/test/java</directory>
                <includes>
                    <include>**/*.groovy</include>
                </includes>
        </testSource>
    </testSources>
</configuration>

      



Update: Or add this at runlevel (see groovy:testCompile

target documentation
):

<execution>
    <goals>
        <goal>testCompile</goal>
    </goals>
    <configuration>
        <sources>
            <source>
                <directory>${pom.basedir}/src/test/java</directory>
                <includes>
                    <include>**/*.groovy</include>
                </includes>
            </source>
        </sources>
    </configuration>
</execution>

      

+1


source







All Articles