Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven wont pick up Spock tests

I've been trying to set up Maven to run my Spock (0.7) tests but to no avail. I've been trying to use groovy-eclipse-compiler as gmaven which is refered to in the Spock documentation is no longer recommended according to its' website. The relevant section of my POM:

<plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
                <verbose>true</verbose>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.8.0-01</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>2.1.8-01</version>
                </dependency>
            </dependencies>
        </plugin>

When I run mvn test I get:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0

Any ideas why maven/surefire just isn't picking up my tests? As the section of the website suggests I've ensured there is a blank file present in src/test/java

like image 239
Keir Avatar asked Mar 21 '23 09:03

Keir


1 Answers

Surefire will pick up Spock tests automatically as long as the test classes match Surefire's naming conventions (*Test etc. by default). First you should check if the test classes actually get compiled and are present under target/test-classes. If not, there is probably something wrong with how you set up the Groovy compiler.

like image 194
Peter Niederwieser Avatar answered Apr 07 '23 05:04

Peter Niederwieser