Cannot run tests with build-helper-maven-plugin on a groovy project

414 views Asked by At

I have a groovy project in Eclipse. I have to change from Gradle to Maven and now I cannot run the tests that exist in it.

Here is the structure of the project:

enter image description here

Here are the contents of the pom.xml:

    <dependencies>
    ...
    <dependency>
        <groupId>org.spockframework</groupId>
        <artifactId>spock-core</artifactId>
        <version>1.0-groovy-2.4</version>
        <scope>test</scope>
    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
                <compilerArguments>
                    <indy />
                    <!-- optional; supported by batch 2.4.12-04+ -->
                ...
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.12</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    ...
                </execution>
                <execution>
                    <id>add-test-source</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/test/groovy</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>

</build>

However, if I do a mvn clean install, the tests are not being ran. Here is the output of the console:

enter image description here

1

There are 1 answers

0
Stanislav Ivanov On

The test cases we have are called Spec and not Test, this is fixed like this:

    <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <configuration>
                <includes>
                    <include>**/*Spec.class</include>
                </includes>
            </configuration>
        </plugin>