On 24/06/2011, at 12:04 AM, James Carr wrote:

> Hi All,
> 
> I want to parameterize our tests to run against different environments
> based on properties passed from the commandline.
> 
> I tried doing the following: -Denvironment=dev
> 
> But I can't seem to access this within a test via the
> System.getProperties() map. Any ideas?


The test task uses an empty map of system properties by default. If you want to 
copy the system properties from the build process (and hence from the 
command-line), you can do something like:

test {
    systemProperties = System.properties
}

Alternatively, you might copy across just the properties you need:

test {
    systemProperties environment: System.properties['environment']
}


--
Adam Murdoch
Gradle Co-founder
http://www.gradle.org
VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply via email to