henry
henry

Reputation: 6106

Preventing parallel execution for Spock and JUnit5 platform

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?

Upvotes: 0

Views: 553

Answers (1)

kriegaex
kriegaex

Reputation: 67417

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.

Upvotes: 0

Related Questions