Home Grails 3.3.1 and passing system properties to test-app
Reply: 0

Grails 3.3.1 and passing system properties to test-app

user937
1#
user937 Published in May 22, 2018, 4:35 am

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
    }
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.303941 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO