# Enclosed JUnit tests are reported twice

**URL:** <https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895>\
**Category:** Old Forum Archive\
**Created:** [July 18, 2013, 6:38pm UTC](https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895 "2013-07-18T18:38:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankit\_Gupta](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ankit_gupta/32/479_2.png) [@Ankit\_Gupta](https://discuss.gradle.org/u/Ankit_Gupta)\
**Post date:** [July 18, 2013, 6:38pm UTC](https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895/1 "2013-07-18T18:38:00Z")

</div>

I am using gradle-1.6 and added some junit tests.

One of my test classes is using the the Enclosed runner. Here is an [example](https://github.com/junit-team/junit/wiki/'Enclosed'-test-runner-example). When I run the test (gradle test), it counts the test twice - once for the inner class and another for the enclosing class. Here is an example:

[![](https://sea1.discourse-cdn.com/gradle/uploads/default/874/7830042de470a3dd.png)](https://d2r1vs3d9006ap.cloudfront.net/s3_images/927755/45.png?1374172555)

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [July 20, 2013, 6:12pm UTC](https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895/2 "2013-07-20T18:12:00Z")

</div>

Hi, I’ve raised GRADLE-2843 for this.

Would you be interested in contributing a fix for this?

---

<div class="post-metadata">

**Author:** ![Ankit\_Gupta](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/ankit_gupta/32/479_2.png) [@Ankit\_Gupta](https://discuss.gradle.org/u/Ankit_Gupta)\
**Post date:** [July 21, 2013, 4:46am UTC](https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895/3 "2013-07-21T04:46:00Z")

</div>

Yes I would love to.

However, I will just need a little guidance. I am not very familiar with Gradle internals and not sure how to fix this. If you point me to a place where I should begin, I can handle from their onwards.

---

<div class="post-metadata">

**Author:** ![luke\_daley](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/luke_daley/32/9890_2.png) [@luke\_daley](https://discuss.gradle.org/u/luke_daley)\
**Post date:** [August 5, 2013, 12:45pm UTC](https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895/4 "2013-08-05T12:45:00Z")

</div>

The test integration code is more involved than you might think so initially. The place to start is: [https://github.com/gradle/gradle/tree/master/subprojects/plugins/src/main/groovy/org/gradle/api/internal/tasks/testing/junit/result](https://github.com/gradle/gradle/tree/master/subprojects/plugins/src/main/groovy/org/gradle/api/internal/tasks/testing/junit/result)

I’d start with writing a test case using the enclosed runner and stepping through the infrastructure code: [https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/integTest/groovy/org/gradle/testing/junit/JUnitCategoriesIntegrationSpec.groovy#L29](https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/integTest/groovy/org/gradle/testing/junit/JUnitCategoriesIntegrationSpec.groovy#L29)

One thing to keep in mind is that the tests run in a separate process, you you’ll need to launch the tests in debug mode then attach the debugger. The test task has a property for this that you’ll need to set.

---

<div class="post-metadata">

**Author:** ![Tisha\_Kuprevich](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@Tisha\_Kuprevich](https://discuss.gradle.org/u/Tisha_Kuprevich)\
**Post date:** [May 30, 2014, 9:28am UTC](https://discuss.gradle.org/t/enclosed-junit-tests-are-reported-twice/1895/5 "2014-05-30T09:28:00Z")

</div>

I can confirm it’s happening for the following configuration:

------------------------------------------------------------ Gradle 1.11 ------------------------------------------------------------

Build time:

2014-02-11 11:34:39 UTC Build number: none Revision:

a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:

1.8.6 Ant:

Apache Ant™ version 1.9.2 compiled on July 8 2013 Ivy:

2.2.0 JVM:

1.7.0\_55 (Oracle Corporation 24.55-b03) OS:

Windows 7 6.1 amd64
