Any idea how to pass gradle parameters to tests? `...
# kotest
p
Any idea how to pass gradle parameters to tests?
Copy code
./gradlew -DproxySet=true -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8080 -Pasdfproxy=asdf :phoenix:testDebugUnitTest --tests PropTest
Copy code
class PropTest: StringSpec({
    "props" {
        System.getProperties().keys
            .filterIsInstance<String>()
            .filter { it.contains("proxy", true) }
            .also { println(it) }
            .shouldNotBeEmpty()
    }
})
And this test is failing.
b
You need to explicitly pass them to Test task sytem properties, because test task runs on forked JVM instance and not the one gradle itself is using.
Copy code
tasks {
  test {
    System.getProperties().forEach { (k,v) -> systemProperty(k, v)
    }
  }
}
🎉 1
👍🏻 1
Do note that it will not pass in
-Pasdfproxy=asdf
, because it's a gradle property and not sys property (-P vs -D)
c
or use env variables instead of properties
b
I don't think env variables are passed in to test fork either
c
I use them for that all the time so i think they are.
👍 2