4

When I used JUnit4 in my projects it seemed that each time a test ran, it would generate a TEST-*.xml report in app/build/test-result. Jenkins would use these XML reports to display failing and passing tests on each build.

I've replaced JUnit4 with JUnit5 with the following in build.gradle:

testImplementation "org.junit.jupiter:junit-jupiter-api:5.3.2"

When running tests with JUnit 5, I'm no longer seeing these TEST-*.xml files being generated. As soon as I drop back to JUnit4, they are.

Is this no longer available in JUnit5 or is there something I have to set on each test in order to get these XML reports?

Programmer001
  • 2,240
  • 2
  • 19
  • 35

1 Answers1

4

Found the solution. In order for the XML reports to be generated for each test you need to include the following in your build.gradle:

testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.2'

As well as:

tasks.withType(Test) {
    useJUnitPlatform()
}

This other post may also be of use to others: JUnit5 integration tests with Gradle 4.6

Programmer001
  • 2,240
  • 2
  • 19
  • 35