JUnit 5, Gradle, and IntelliJ: Publishing test events for tooling API consumers

plugins

(Mike Kobit) #1

JUnit 5 development is in progress, and there is gradle/gradle#1037 for integrating it natively into Gradle. Right now, the JUnit 5 team has built a simple plugin that can be used until the support is built directly in.

IntelliJ can delegate Gradle run actions to Gradle. I believe that IntelliJ uses the tooling API to launch these tests as well as receive events for them.

When using the current JUnit 5 plugin and the delegating run actions, IntelliJ displays “No events found”, which makes sense.

What I’m trying to figure out is, how can the current JUnit 5 plugin be adapted to publish test events so that IntelliJ can receive them?


(Benjamin Muschko) #2

The external JUnit 5 plugin calls off to the JUnit Platform Console, an external Java program running in a forked JVM. Emitted test events cannot be captured. In order to consume the test events, the plugin would have to use the JUnit Platform Launcher API directly so you can implement the event listeners e.g. by IntelliJ. I guess the plugin would have to implement those listeners and write specific events to a file. Then at runtime IntelliJ could pipe the file(s) and do something with it. I think the best way to go about it is to ask the JUnit 5 team directly as they are currently implementing the plugin.

In practice there really needs to be a tighter integration of Gradle and JUnit 5. That’s what we are planning to approach with gradle/gradle#1037. Please vote for the issue if you want it to get a higher priority on our end.