Many CI/CD servers already support reading JUnit XML reports and integrate well with code-review and merge-requests. However Mill is still more of a Scala niche tool.
This repo contains a tiny Scala utility that can transform Mill test json reports into JUnit XML reports.
ammonite generate-junit-report.sc --help
ammonite generate-junit-report.sc TEST_ID TEST_NAME TARGET_JUNIT_XML_FILE SOURCE_MILL_JSON_FILE...
TEST_ID
and TEST_NAME
have no special meaning and are for you to decide. You can provide many json files as input and they will be aggreated into a single target xml file.
Suppose you have a build.sc
file like:
// build.sc
import mill._, scalalib._
object foo extends ScalaModule {
def scalaVersion = "2.13.1"
object test extends Tests {
def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.7.1")
def testFramework = "utest.runner.Framework"
}
}
After running mill foo.test
you will find mill's json report at
out/foo/test/test/dest/out.json
.
To convert it into JUnit XML format, execute the following ammonite script:
> ammonite generate-junit-report.sc "foo.test" "Foo tests" "foo-junit.xml" "out/foo/test/test/dest/out.json"
that will generate foo-junit.xml
.