On 08/10/2010, at 1:05 AM, richardm wrote:

> 
> Hi, 
> 
> How do you set the forkmode to once for junit tests?  
> 
> In the user guide (chapter 18) it states "Per default the tests are run in a
> forked JVM and the fork is done per test. You can modify this behavior by
> setting forking to false or set the forkmode to once."

I suspect you're using an out-of-date user guide. Testing is discussed in 
chapter 20 for Gradle 0.9-rc1, not chapter 18. You can find the relevant 
chapter here: 
http://www.gradle.org/0.9-rc-1/docs/userguide/java_plugin.html#sec:java_test

To summarise, the test task now has a 'forkEvery' property which specifies how 
many test classes to execute in a JVM before reforking. By default it is set to 
'infinity'. That is, the default is the equivalent to forkmode = once. So you 
shouldn't have to do anything to get forkmode = once.


> 
> I couldn't see any examples of how to do this, apart from the Java
> quickstart chapter which shows how to add a system property:
> 
> test {
>    options.systemProperties['property'] = 'value'
> }
> 
> so I had a try and added the following:
> 
> test {
>    options.systemProperties['forkmode'] = 'once'
> }
> 
> However when I run the build I get the following error:
> 
> * What went wrong:
> A problem occurred evaluating root project 'uwm'.
> Cause: No such property: systemProperties for class:
> org.gradle.api.tasks.testing.junit.JUnitOptions
> 
> Can anyone advise?  I'm struggling to find examples in the documentation.

Again, I think you're using a userguide for an older version of Gradle. The 
same example for Gradle 0.9-rc1 can be found here: 
http://www.gradle.org/0.9-rc-1/docs/userguide/tutorial_java_projects.html

Please make sure that you use the userguide for exactly the same version of 
Gradle. The test task got a major overhaul between 0.8 and 0.9. So anything in 
the 0.8 user guide about testing is unlikely to work with 0.9.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz

Reply via email to