Skip to content

Is there any way to control how many of a type of test run at the same time? #2185

Answered by Vampire
efenderbosch-atg asked this question in Q&A
Discussion options

You must be logged in to vote

You could configure the parallelism overall.
That will be effective for all tests though and still more tests can run in parallel due to work-stealing.

In situations like you described I usually recommend exactly that.
If you want the limit for all tests, have a global Spock extension that creates a Semaphore with 10 permits, then acquire it in an according interceptor before calling proceed() and release it in a finally block.

If you want to limit only specific tests or have several independent pools, make an annotation-driven local Spock extension so that only annotated tests are affected and you could configure a pool identifier and have one semaphore per pool

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by efenderbosch-atg
Comment options

You must be logged in to vote
1 reply
@Vampire
Comment options

Vampire Jul 9, 2025
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants