I am bumping into an issue in my integration test. My code uses a system property (System.getProperty(...) ) and I am not being able to set the system property when running the integration test. Any idea on how to define system properties that are visible inside code running in integration test?
I am using Grails 3.3.1. Slimmed down example of integration test not seeing the system property:
package injecttest
import grails.testing.mixin.integration.Integration
import grails.transaction.*
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification
@Integration
@Rollback
class C1ITSpec extends Specification {
void "test system property readable inside test"() {
String val = System.getProperty("var1", "ERROR")
expect:"system variable to match value passed as '-Dvar1=OK' in command line"
"OK" == val
}
}