I need to set some test configuration like a set of System Properties and JVM settings between my unit tests (plain test task) and my integration tests(tests that end in “IntegrationTest”) I tried this:
test {
systemProperty 'opt.terracotta', 'true'
systemProperty 'opt.dev.home', '/Users/pswenson/dev/sag/optimize/trunk'
systemProperty 'base.config.path', '/Users/pswenson/dev/sag/opt/trunk/modules/ae/src/main/resources/conf'
//tuning the included/excluded tests
include '**/*UnitTest.*'
jvmArgs '-Xms128m', '-Xmx512m', '-XX:MaxPermSize=128m'
}
task integrationTests(type: Test) {
println ("tcsytemprop = ${System.getProperty('opt.terracotta')}")
include '**/*IntegrationTest.*'
}
the tcsystemprop was output as null, so the test configuration isn’t shared just by declaring a task type “Test”
Hello phil, a system property defined in a test task is passed to the JVM that executes the tests. So when you do
test{
systemProperty 'myProp', 'somePath'
}
the systemProperty myProp is not available in other sections of your build script. Its only available in the context of your executed tests, as they use a JVM, that is configured with this systemProperty.
to share a configuration between your integrationTests task and your test task you can do:
in your the configuration of your task ‘test’ will allways print “testsystemprop = NULL”, as you try to load a SystemProperty on the java instance the gradle build uses.
All tasks of type ‘Test’ are executed in a seperate jvm instance. The systemProperty method of the Test task is used to pass system properties that you need in your tests to this newly created JVM instance. what you can do to check that your configuration is correctly, you can write a simple unit test that verifies, that your needed systemproperties are set correctly.