Skip to content

munit and junit test reporting does not work when sbt runs tests in fork mode #8665

@mwisnicki

Description

@mwisnicki

Tracer Version(s)

1.47.3~4a85e1fff5

Java Version(s)

21.0.2

JVM Vendor

Eclipse Adoptium / Temurin

Bug Report

When sbt is configured to run tests in fork mode, neither munit nor junit tests are reported to datadog.
Forking mode works for scalatest.

Expected Behavior

munit with Test/fork := true reports tests to datadog.

Reproduction Code

build.sbt

scalaVersion := "3.3.5"
Test / fork := true // comment it out to make this work
libraryDependencies ++= Seq(
  "junit" % "junit" % "4.13.2" % Test,
  "com.github.sbt" % "junit-interface" % "0.13.3" % Test,
  "org.scalameta" %% "munit" % "1.1.0" % Test,
)

src/test/scala/ExampleTest.scala

class ExampleJunitTest {
  @org.junit.Test
  def hello(): Unit = {
    println("Hello from JUnit")
  }
}

class ExampleMunitTest extends munit.FunSuite {
  test("hello") {
    println("Hello from MUnit")
  }
}

project/build.properties

sbt.version=1.10.11

Simplified snippet from .github/workflows/test.yaml

jobs:
  tests:
    steps:
      - uses: sbt/setup-sbt@v1
      - uses: actions/setup-java@v4
        with:
          distribution: temurin
          java-version: 21
      - uses: datadog/test-visibility-github-action@v2
        with:
          languages: java
          api_key: ${{ secrets.DATADOG_API_KEY }}
          service: foo
      - run: sbt test

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions