Running JUnit ActiveTestSuite

Hi all,

Really new to Gradle so apologies if I stumble through my issue.

I’m using ActiveTestSuite provided by JUnit, this insures any test added to the test suite will be ran in it’s own thread. I’m using this to exercise my codebase for concurrency issues and data leakage. I have the test suite successfully running in Eclipse. In the active test suite I’ve add two standard test suites with a number of tests(the two test suites are identical). What this should mean is I have two similar test suites executing concurrently in different threads. As I said this is working in Eclipse, the problems occur when I try to run the ActiveTestSuite from Gradle.

Gradle reports what appears to be JUnit lifecycle errors:

java.lang.AssertionError: Unexpected start event for test_insert_positiveFlow_allFields(my.test.MemberTest)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestEventAdapter.testStarted(JUnitTestEventAdapter.java:56)
	at org.junit.runner.notification.RunNotifier$3.notifyListener(RunNotifier.java:87)

and

java.lang.AssertionError
	at org.gradle.api.internal.tasks.testing.processors.TestOutputRedirector.setOutputOwner(TestOutputRedirector.java:49)
	at org.gradle.api.internal.tasks.testing.processors.CaptureTestOutputTestResultProcessor.completed(CaptureTestOutputTestResultProcessor.java:80)
	at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.completed(AttachParentTestResultProcessor.java:56)
	at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.completed(AttachParentTestResultProcessor.java:56)
	at org.gradle.api.internal.tasks.testing.junit.TestClassExecutionEventGenerator.completed(TestClassExecutionEventGenerator.java:83)

There are other similar unexpected event assertions thrown during the test execution. I’ve dug about a bit and can’t see any examples of the ActiveTestSuite and Gradle with respect to this type of issue.

The task I’ve declared is:

task parallelTestSuite(type: Test){

    //gradle.startParameter.continueOnFailure = true
    scanForTestClasses = false
    includes = ['**/*MyActiveTestSuite.class']
  	
	environment "SERVER_DIR", "."
	maxHeapSize = "1024m"

	workingDir "../../"
	afterTest { desc, result ->
		println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
	}

}

I’ve tried setting the fork behaviour but to be honest the default configuration is what I want, i.e. parallel threads in the same JVM. Any help much appreciated, again go easy on me I’m new :slight_smile:

Thanks.

Anybody got any ideas as to what I’m doing wrong, or is gradle’s JUnit integration not cable of running the same tests in different threads?