# Running JUnit ActiveTestSuite

**URL:** <https://discuss.gradle.org/t/running-junit-activetestsuite/22477>\
**Category:** Help/Discuss\
**Created:** [April 27, 2017, 12:57pm UTC](https://discuss.gradle.org/t/running-junit-activetestsuite/22477 "2017-04-27T12:57:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshields](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jshields](https://discuss.gradle.org/u/jshields)\
**Post date:** [April 27, 2017, 12:57pm UTC](https://discuss.gradle.org/t/running-junit-activetestsuite/22477/1 "2017-04-27T12:57:41Z")

</div>

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 🙂

Thanks.

---

<div class="post-metadata">

**Author:** ![jshields](https://avatars.discourse-cdn.com/v4/letter/j/e47774/32.png) [@jshields](https://discuss.gradle.org/u/jshields)\
**Post date:** [May 2, 2017, 6:07am UTC](https://discuss.gradle.org/t/running-junit-activetestsuite/22477/2 "2017-05-02T06:07:08Z")

</div>

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?
