Thanks for the correction @st_oehme, but we got a bit distracted from solving my actual problem.
Since the GradleRunner forks a process with a separate JVM and context, it does not have the gradle project properties that I provide on the command line when I run
./gradlew test -Pusername=foo -Ppassword=bar
I have explicitly set up some static gradle project properties in my integration tests but how do I solve this problem for credentials? I cannot hard code a username and password in plain text in the source code.
I thought the system properties should work, but for some reason it hasn’t, but that also doesn’t feel like a safe way to pass credentials. For example I suspect those system properties live outside the lifecycle of the java process and only would disappear on a reboot or when they are overwritten.
My thinking is that the best way to do this is to pass the Gradle project object to my integration test class. Or alternatively, initialise my integration test class to look up the gradle project object which has the variables that I need. Any tips on how to do this?