Closed lefou closed 3 years ago
@lefou
Looks like running JUnit tests from SBT produces correct reports if there are any failed tests.
Are you sure that the issue is with junit-interface
and not with Mill
or LambdaTest
?
If you are sure, then what exactly is wrong with the reports?
The same example test suite is not detected to fail by sbt (which uses junit-interface). But it is properly detected to fail when run with Maven and Junit.
So, Junit properly runs the tests in all three build tools and also always detects one failure. But when junit-interface is used, the failure is not property reported. I think junit-interface is loosing some information, e.g. by ignoring some part of the test name.
Here are the build scripts I used:
sbt:
name := "Example"
libraryDependencies += "com.novocode" % "junit-interface" % "0.11"
libraryDependencies += "de.tototec" % "de.tobiasroeser.lambdatest" % "0.7.0"
libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.30"
Maven:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>jpademo</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>de.tototec</groupId>
<artifactId>de.tobiasroeser.lambdatest</artifactId>
<version>0.7.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Fixed in release 0.12
.
Here is the output of a a minimal repro:
This is the test class
example/test/src/example/Test.java
:And the build file
build.sc
:Here's the outcome gathered by mill:
Looks like all three tests are mixed up. If I reduce the example to only include one failing test, the test failure is properly detected.
I already checked that the tests created by the JUnit Runner of
FreeSpec
/LambdaTest
get unique names: https://github.com/lefou/LambdaTest/blob/0.7.0/src/main/java/de/tobiasroeser/lambdatest/junit/FreeSpecRunner.java#L45