Running JUnit ActiveTestSuite

(Jonathon Shields) #1

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(
	at org.junit.runner.notification.RunNotifier$3.notifyListener(


	at org.gradle.api.internal.tasks.testing.processors.TestOutputRedirector.setOutputOwner(
	at org.gradle.api.internal.tasks.testing.processors.CaptureTestOutputTestResultProcessor.completed(
	at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.completed(
	at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.completed(
	at org.gradle.api.internal.tasks.testing.junit.TestClassExecutionEventGenerator.completed(

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.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:


(Jonathon Shields) #2

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?