5

In some other testing frameworks I'm used to tagging tests, eg @really_slow, @front_end

And then running different batches of tests, like I might want to set up a build slave to run all the really_slow tests, and might want to run all the tests tagged as front end but none that are marked as really slow.

To run my spock+geb tests in grails at the moment I just run grails test-app functional:

How do I tell it to run a subset?

The Trav
  • 1,955
  • 3
  • 22
  • 30

1 Answers1

4

You could use JUnit suites with @Category. Or you could use a SpockConfig.groovy with the following contents:

runner {
    include foo.bar.FrontEnd, foo.bar.BackEnd
    exclude foo.bar.Slow
}

Here, foo.bar.FrontEnd, foo.bar.BackEnd, and foo.bar.Slow are your own annotations. To activate the configuration file, you have to set a spock.configuration system property pointing to it.

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259
  • 1
    Great answer, where can I find documentation on the SpockConfig.groovy file? – Alison Feb 23 '13 at 01:55
  • 1
    It isn't currently well documented. You can find some bits in the Javadoc (e.g. http://javadoc.spockframework.org/latest/spock/config/RunnerConfiguration.html). The default location for the config file is `~/.spock/SpockConfig.groovy`. If necessary, you can set a different file path via the `spock.configuration` system property. – Peter Niederwieser Feb 23 '13 at 02:46
  • 1
    I'm having trouble getting that to work. I get an error that says the config file is wrong but it doesn't say what line. Is there a command-line way to specify the spock configuration? – Alison Feb 26 '13 at 03:28
  • Similar problem, complaining the Spock config file cannot compile, when it should (based on the example and IntelliJ compiling it without issues) `import com.myproject.test.ReadOnly runner { include ReadOnly } ` – Marcos Carceles Aug 18 '14 at 12:05
  • Apparently this is the reason: https://code.google.com/p/spock/issues/detail?id=184 – Marcos Carceles Aug 18 '14 at 12:52