I’m migrating my junit test cases from 4 to 5.
In Junit 4 I have test suites.
The new Junit 5 “test suites” runs fine from Eclipse but not from commandline.
If I run the AllTests.class in Eclipse(2019.6) then TaskTest and JobTest are also run.
But that does not work with Gradle.
If I remove the include statement in Gradle then TaskTest and JobTest are run. AllTests is not run properly because is doesn’t have a method annotated with @Test.
But I don’t understand why the @SelectClasses annotation doesn’t work with Gradle.
Check to make sure that you’re using the org.junit.jupiter.api package for the @Test annotation. Junit didn’t switch the actual annotation name going from 4 -> 5 like they did for most of the rest. It’s very easy to accidentally use the wrong import.
The problem is that AllTests is a Junit 4 construction. And it can’t be run with Junit 5.
Eclipse is smart enough to figure this out and use the right “runner”.
The solution is to delete the AllTests.java and remove the include statement in the gradle build file.
I just found out that I can right-click on a package or the test source folder and select Run As Junit Test to get a similarly behaviour as my AllTests.
I had the exact same problem except it was with the @test annotation from junit 4 and intellji running it when Gradle was looking for junit 5 annotations and silently passing everything by executing none of the tests.
i am trying to create a test suite for Unit test of android application, but it always fails with different kinds of configuration error, one among that is as follows,
Error: Test events were not received android
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ‘:appModules:factList:testDebugUnitTest’.