Variables gradle

Good afternoon, I’m trying to run a test that needs a variable in an imported class, but I’ve tried countless ways to override this variable,
osts = System.getProperty (“session.jedis.sessionHost”, env.getOrDefault (“REDIS_HOST”, “localhost: 6379”)). split (",");
this would be inside the code, but as I can’t overwrite it, the test always looks for the redis locally, and I wanted to use a remote redis, I’ve tried to use gradle -P -D and set this variable

Hi,

Gradle forks VM to run tests, so you need to pass properties to forked VM to use them within tests. Something like this:

tasks.named('test', Test).configure {
    systemProperty 'session.jedis.sessionHost', System.properties['session.jedis.sessionHost']
}

Then you run test with -D flag like this: gradle test -Dsession.jedis.sessionHost=foobar.

https://docs.gradle.org/current/userguide/java_testing.html#sec:test_execution

Thanks for the help, but it didn’t work for some reason he insists on looking at localhost for redis. Includes the bashrc variable and is now giving NoClassDefFoundError