How to provide connection info to Gradle test?

I’m using Eclipse Neon 4.6.0 with Buildship 1.0.18 v20160817. I’m working on a simple Java project that connects to a remote host with a user and password. I’m trying to provide the URL, user and password for my Gradle test. I can use a BufferedReader in a JUnit test to provide the info via console input, but that doesn’t work with Gradle.

Any suggestions on how to do this for my Gradle test?

Thx

Here are the three steps to pass arguments through Gradle into a test:

  1. pass the arguments to Gradle as project properties (add -Pusername=foo in the arguments tab in Eclipse)
  2. pass them to the test VM using the Test task API (test.systemProperty 'username', project.findProperty('username'))
  3. use System.getProperty('username') inside your test

The benefit is that this also works on the command line or on a CI server.

Unless I’m overlooking the obvious (quite possible), it looks like that’s still storing credentials in code.