JUnit tests fail if test suite containes interfaces


In my Java project I have defined some interfaces in my JUnit 4 tests, and when I run my test suite with gradle the build fails with an initialization error. What seems to be happening if I understand the stacktrace correctly, is that gradle’s ‘JUnitTestClassExecuter’ tells the JUnit runner to run the interfaces as they were test classes, which obviously fails. You can have a look at the stacktrace here.

Could you please provide a sample project that exhibits the problem.

I’m trying to reproduce to issue in a sample project and so far didn’t manage to, it looks like it’s something related to that project but cannot figure out what exactly. I’ll post an update as soon as I’m able to reproduce the issue in a sample project.

I think I found the root of the problem, and it probably was just me being dumb: the interface was named something like ‘MyInterfaceTest’, so the JUnit runner was seeing that class as a test class and tried to instantiate and execute it. Renaming that interface made the failure go away. I wonder why that was working just fine with Maven though.

Would you be able to push an example project to GitHub, or provide it some other way?