Gradle doesn't pass System properties to test classes
Asked Answered
P

1

7

I am using Selenium and Spock for testing my application. Running tests that need System properties from Maven or my IDE works like a charm, but Gradle is getting null values.

@Shared
private int waitTimeout = System.getProperty("waitTimeout", "10").toInteger()

@Shared
protected String apolloURL = System.getProperty("apolloURL")

Maybe I am doing something wrong?

Paratroops answered 25/7, 2013 at 7:17 Comment(0)
C
15

See Test task type in the Gradle Build Language Reference.

test {
    systemProperty "waitTimeout", "20"
    systemProperty "apolloURL", "..."
}
Checkroom answered 25/7, 2013 at 7:40 Comment(1)
If you're using junit 5, you may also encounter this issue and need its workaround: https://mcmap.net/q/1477926/-setting-system-properties-when-using-junitplatformSqueamish

© 2022 - 2024 — McMap. All rights reserved.