Enclosed JUnit tests are reported twice


(Ankit Gupta) #1

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


JUnit tests with "Enclosed" runner are run twice
(Luke Daley) #2

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

Would you be interested in contributing a fix for this?


(Ankit Gupta) #3

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.


(Luke Daley) #4

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

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

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.


(Tisha Kuprevich) #5

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