How to set a different system property for each jmv gradle spawning during parallel testing?

Gradle allows me to run multiple jvms for testing as follows:

test { maxParallelForks = 10 } 

Some tests for the application that I have require a fake ftp server that needs a port. This is pretty easy to do with one jvm:

 test { systemProperty 'ftpPort', 10000 } 

However, when running in parallel, I will need to start 10 fake ftp servers. How to add a custom system property for every jvm created by gradle?

Something like:

 test { maxParallelForks 10 customizeForks { index -> systemProperty 'ftpPort', 10000 + index } } 
+8
testing gradle
source share

No one has answered this question yet.

See related questions:

330
How to run only one test class on gradle
61
How to pass JVM parameters from bootRun
8
Gradle: optimize current tests in parallel
4
Set Ant property from Gradle not working
3
Passing system properties from the command line to my application via gradle
2
Build and run all junit tests in parallel with each test class in its own JVM (parallelization by classes, not by method)
one
How to add property to test JVM using Gradle?
one
In Gradle, how to set a unique system property before each execution of the JUnit test class?
0
Setting system properties for bending tests
0
Grails: How to set a system property

All Articles