Groovy Test cases are not running when doing a mvn clean install but the test cases written in Java are getting executed

75 Views Asked by At

In my project test cases are written in both java and groovy. When I run the groovy test case individually it is getting executed. However when I run mvn clean install, only the java test cases are getting executed. In pom file the dependency is as follows:

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

<!-- Compiles Groovy code. -->
<plugin>
    <groupId>org.codehaus.gmavenplus</groupId>
    <artifactId>gmavenplus-plugin</artifactId>
    <version>1.12.1</version>
    <executions>
        <execution>
            <goals>
                <goal>compileTests</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<!-- Run Spock Tests -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.0.0</version>
    <configuration>
        <useFile>false</useFile>
        <includes>
            <include>*.*</include>
        </includes>
    </configuration>
    <!-- Run Spock tests with JUnit not TestNG -->
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit47</artifactId>
            <version>3.0.0</version>
        </dependency>
    </dependencies>
</plugin>
1

There are 1 best solutions below

0
grzegorzgrzegorz On

You correctly build tests with gmavenplus plugin. If test class files are there in the target directory, try using exactly version 3.0.0-M3 of the surefire plugin. I didn't check 3.0+ versions but this one seems to be the only version from 3.0 family to run Groovy tests. If this is successful you could try also newest versions to find out the one supporting Groovy tests.