You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
munit and junit test reporting does not work when sbt runs tests in fork mode #8665
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
classExampleJunitTest {
@org.junit.Testdefhello():Unit= {
println("Hello from JUnit")
}
}
classExampleMunitTestextends munit.FunSuite {
test("hello") {
println("Hello from MUnit")
}
}
project/build.properties
sbt.version=1.10.11
Simplified snippet from .github/workflows/test.yaml
Hi @mwisnicki, thank you for reporting this!
The reason tests are not reported to Datadog is that the DD tracer is only injected into the parent SBT process, and not into the forked JVMs that execute the tests.
Could you please try using the java-instrumented-build-system: all GitHub Action setting? That will ensure the tracer is injected into every JVM.
java-instrumented-build-system seems to have helped getting test results in fork mode however I've noticed that regardless of this setting and whether forking is enabled, test runs and test suites are disconnected from test session and module. Both for munit and junit. I'm surprised that session didn't propagate even in non-fork mode.
Additional minor problem is that I have warning Warning: dd-java-agent is being initialized more than once but that's understandable, it's injected by github action and by sbt-datadog plugin. I'll have to figure out how to disable injection from the latter in tests but for now I disabled it completely to eliminate any interference.
Finally there's I think unrelated issue that DataDog sometimes stops updating github comment with reports. I think I saw it before so it's likely not caused by this.
Another strange problem - I have 2 jobs in workflow triggered by PR but now only see reports from one of them.
They are set up identically except 2nd one uses branch instead of branch merged to main.
The logs from both seem correct.
test runs and test suites are disconnected from test session and module
Could you provide more context here please?
All test runs are present but around half of individual test runs have their Session Trace tab empty (it never arrives):
It's even weirder when I go see sessions.
My workflow has 2 jobs so I expect 2 sessions.
Instead there are 2-3 sessions. Sometimes one is green but most of them grey and marked as skipped although they took more or less same time.
Their test suites and test runs tabs are empty (no matching results found).
Hi @mwisnicki, thank you for these details, they helped a lot with reproducing the problem! The fix is included in the Java tracer release v1.48.0 that was rolled out yesterday. Could you please try it out and let me know if it fixes the issue?
Activity
nikita-tkachenko-datadog commentedon Apr 3, 2025
Hi @mwisnicki, thank you for reporting this!
The reason tests are not reported to Datadog is that the DD tracer is only injected into the parent SBT process, and not into the forked JVMs that execute the tests.
Could you please try using the
java-instrumented-build-system: allGitHub Action setting? That will ensure the tracer is injected into every JVM.mwisnicki commentedon Apr 4, 2025
java-instrumented-build-systemseems to have helped getting test results in fork mode however I've noticed that regardless of this setting and whether forking is enabled, test runs and test suites are disconnected from test session and module. Both for munit and junit. I'm surprised that session didn't propagate even in non-fork mode.Additional minor problem is that I have warning
Warning: dd-java-agent is being initialized more than oncebut that's understandable, it's injected by github action and by sbt-datadog plugin. I'll have to figure out how to disable injection from the latter in tests but for now I disabled it completely to eliminate any interference.Finally there's I think unrelated issue that DataDog sometimes stops updating github comment with reports. I think I saw it before so it's likely not caused by this.
mwisnicki commentedon Apr 4, 2025
It's interesting that even with
Test/fork := falseI see two OpenJDK and dd.trace startup messages as well asmwisnicki commentedon Apr 4, 2025
So an example test run has following tag:
while disconnected but probably related test session looks like this:
Month ago with
library_version: 1.46.1~8e0205904b(now 1.47.3) it looked similar but used to work.mwisnicki commentedon Apr 4, 2025
Another strange problem - I have 2 jobs in workflow triggered by PR but now only see reports from one of them.
They are set up identically except 2nd one uses branch instead of branch merged to main.
The logs from both seem correct.
mwisnicki commentedon Apr 4, 2025
I'll try to narrow down which version introduced the break.
nikita-tkachenko-datadog commentedon Apr 4, 2025
Could you provide more context here please?
mwisnicki commentedon Apr 7, 2025
All test runs are present but around half of individual test runs have their
Session Tracetab empty (it never arrives):It's even weirder when I go see sessions.
My workflow has 2 jobs so I expect 2 sessions.
Instead there are 2-3 sessions. Sometimes one is green but most of them grey and marked as skipped although they took more or less same time.
Their test suites and test runs tabs are empty (no matching results found).
When I downgrade to 1.46.1 things start to work:
mwisnicki commentedon Apr 7, 2025
1.47.0 introduced the break
mwisnicki commentedon Apr 7, 2025
Which is a shame since it also introduced much needed fix for #8445
nikita-tkachenko-datadog commentedon Apr 10, 2025
Hi @mwisnicki, thank you for these details, they helped a lot with reproducing the problem! The fix is included in the Java tracer release v1.48.0 that was rolled out yesterday. Could you please try it out and let me know if it fixes the issue?
mwisnicki commentedon Feb 18, 2026
Thanks, it looks correct. Sorry for taking so long to check :D
mwisnicki commentedon Feb 27, 2026
Unfortunately I was incorrect. Looks like forking still breaks test upload from munit with latest dd-trace-java.
I'll try gather more information and open a new ticket later