How to use in Junit class

I have 2 properties in as


And I want to use it my Junit test.
How can I achieve this?

The gradle Test task offers a systemProperty method to create jvm system properties.

test {
systemProperty 'host',
systemProperty 'port', project.port

THen in your java Unit test


If you have tons of them, you can use

test {
systemProperties =

to copy all your gradle project properties to the Test Jvm system properties

test {
systemProperty ‘host’,
systemProperty ‘port’, project.port

This is working for me.

How can I put all in one file like project.proiperties or and use it with systemProperties?

The following should work. See ConfigSlurper API or example
test {
systemProperties = new ConfigSlurper().parse(file('