Prometheus Blogs

Configuring Spock integration tests, written in Groovy, with the Maven failsafe plugin

Sunil Bhaskarla

Maven failsafe plugin works fine with the normal JUnit test cases. But what if you wanted to use the Spock framework for your integration tests? This post will focus on the configuring Spock tests written in Groovy because the maven build configuration is tricky when it comes to Groovy. Initially, I used a “.groovy” file extension in the maven failsafe plugin configuration Include entry but the Spock tests did not run at all in my experience. After trying out several things the only way I found a solution to the problem was to add another Include configuration entry with a “.java” file extension for the same Spock Groovy class and it worked. Here’s the relevant part of the maven POM build configuration shown below.

Reader Comments
  1. Ittai said... about 5 years ago
    Hi, Did you end up finding why or filing a bug? I just stumbled on to this since we have a mixed Java/Scala codebase and so our maven config always contained both above lines. New OSS project with only Scala surfaced this...
  2. Sunil Bhaskarla said... almost 5 years ago
    Hi Ittai, I don't know the real reason but my only guess was to realize Groovy complied into Java so I added an explicit instruction. And I didn't file a bug. Not a bad idea to create one if one doesn't exist by now.

Prometheus Computing, LLC. © 2008 — 2021