0

I maintain a tool that acts as a JUnit5 platform test runner.

When it is supplied with Spock tests, I'd like to prevent them from running in parallel, regardless of the options set by the user.

For Jupiter tests this can be done by setting a system property

junit.jupiter.execution.parallel.enabled = false

Although spock accepts a property named runner.parallel.enabled in its configuration file, it does not look like this can be overriden by anything at the system level.

Is there a simple way to prevent parallel execution without having to make changes to a project's configuration?

Can this somehow be done in a generic way for anything using the junit5 platform?

henry
  • 5,923
  • 29
  • 46
  • Why do you think your runner should overrule another developer's Spock configuration? – kriegaex May 25 '23 at 13:47
  • @kriegaex because maintaining a mutation testing framework is complicated enough without having to worry about an additional layer of concurrency. – henry May 25 '23 at 15:01
  • Again, should not the developer using your framework decide if and how to configure her test engines to run single-threadedly? I think that enforcing that inside your own framework is simply the wrong place. The user manual should advise users to disable parallel execution, if your framework absolutely needs it. But actually, tests should be independent of each other, no matter if mutated or not. – kriegaex May 26 '23 at 09:24
  • You could, as described in the [Spock manual](https://spockframework.org/spock/docs/2.4-M1/all_in_one.html#spock-configuration-file), set the `spock.configuration` system property to point to a custom Spock config file placed on the classpath by your framework. But that would override any user-configured options, or other Groovy code contained in her own Spock config. So that is not advisable either. – kriegaex May 26 '23 at 09:28

1 Answers1

0

Like I said in my comments, I think that your approach to override user settings from your runner is wrong. You should leave that decision to your users. They could either define two separate test runs with and without mutation testing in their Maven or Gradle configurations and leave it up to them to decide, which test execution to run with which Spock config. Or maybe they even want to run mutation tests in parallel mode, if their tests can handle that. The decision is not up to you.

You could also advise them in your user manual to do something like this in their Spock configs:

runner {
  parallel {
    enabled System.getProperty('mutationTestActive', 'false') != 'true'
  }
}

Your framework would then simply need to set that property, and Spock would disable parallel mode accordingly.

kriegaex
  • 63,017
  • 15
  • 111
  • 202