1
votes

For some reason the Maven Grails integration fails to run Spock (integration phase)* tests

The tests are executed fine with the normal grails command grails test-app, but the Maven version mvn grails:test-app fails. I've followed this example in the setup.

My grails BuildConfig.groovy has the following

dependencies {
  // ... irrelevant dependencies omitted
  test 'org.spockframework:spock-grails-support:0.7-groovy-2.0'
}

plugins {
  // ... irrelevant plugins omitted
  test(":spock:0.7") { exclude "spock-grails-support"
}

And the Maven pom.xml

<dependencies>
  <dependency>
    <groupId>org.spockframework</groupId>
    <artifactId>spock-core</artifactId>
    <version>${spock.version}</version>
    <scope>test</scope>
  </dependency>    
</dependencies>

<build>
<plugins>
 <plugin>
    <groupId>org.grails</groupId>
    <artifactId>grails-maven-plugin</artifactId>
    <version>${grails.version}</version>
    <configuration>
      <fork>true</fork>
    </configuration>
    <extensions>true</extensions>
  </plugin>

  <plugin>
    <groupId>org.spockframework</groupId>
    <artifactId>spock-maven</artifactId>
    <version>${spock.version}</version>
    <executions>
      <execution>
        <goals>
          <goal>find-specs</goal>
        </goals>
      </execution>
    </executions>
  </plugin>
</plugins>
</build>

where Grails version is 2.2.4 and Spock version is 0.7-groovy-2.0

The bottom line is that the Spock tests just don't get executed at all. What's up with that?

* So far only have written integration phase tests with Spock

1

1 Answers

3
votes

Plugin dependencies should be specified in pom.xml instead of BuildConfig in mavenized projects. Replace entries for spock in BuildConfig (remove spock plugin and the dependency to the support jar as well) with the below entry in pom.xml.

<dependency>
  <groupId>org.grails.plugins</groupId>
  <artifactId>spock</artifactId>
  <version>0.7</version>
  <scope>runtime</scope>
  <type>zip</type>
  <exclusions>
    <exclusion>
      <groupId>org.spockframework</groupId>
      <artifactId>spock-grails-support</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<dependency>
  <groupId>org.spockframework</groupId>
  <artifactId>spock-grails-support</artifactId>
  <version>0.7-groovy-2.0</version>
  <scope>runtime</scope>
</dependency>

You would not need spock-maven maven pluing as well, I suppose