Records test results that JUnit Platform streams while the enclosed steps run, using the Open Test Reporting format.

The step listens on a socket on the loopback interface of the agent. Test JVMs started by the enclosed steps connect to it and send events as tests start and finish, so:

When the block ends, whether or not it succeeded, the results are recorded just like the junit step would, and the step returns the same summary.

withOpenTestReporting {
    sh 'mvn -B test'
}

Requirements: JUnit Platform 6.1 or later, with org.junit.platform:junit-platform-reporting on the test runtime classpath, and tests running in the same network namespace as the agent process, so that they can reach its loopback interface. Being on the same machine is not enough when they run in a separate container. With the default settings, the JUnit configuration parameters junit.platform.reporting.open.xml.enabled=true and junit.platform.reporting.open.xml.socket=port are added to the JAVA_TOOL_OPTIONS environment variable so that no change to the build is needed. The port is also available in the JUNIT_OTR_SOCKET_PORT environment variable.

Open Test Reporting files (open-test-report.xml) can also be recorded with the junit step, without streaming.