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
Need is_ignored custom tags (and optional skip reason) on agent-reported ignored tests in CI with javaagent + Gradle.
Current behavior
onTestIgnore does start → skip → end synchronously; app RunListener.testIgnored runs outside that window, so Span.current() / manual DDTest either don’t tag the agent test or create a second session (suite conflicts).
Desired behavior
Hook to set tags on the same test span Datadog creates for @Ignore / fireTestIgnored, e.g. public API, TestEventsHandler callback, or documented extension point.
I try to set custom tag on @Ignore test with Datadog Test Optimization with Java Tests on an android project, and notice that there is no active span, as Span.current() is not working for @Ignore test.
Below is the sample code:
class TestIgnoredListener : RunListener() {
override fun testIgnored(description: Description) {
Span.current().setAttribute("is_ignored", true)
}
}
class CustomRobolectricTestRunner(testClass: Class<*>) : RobolectricTestRunner(testClass) {
...
override fun run(notifier: RunNotifier) {
notifier.addListener(TestIgnoredListener())
super.run(notifier)
}
...
}
@RunWith(CustomRobolectricTestRunner::class)
class CreateThreadPickMediaTest {
...
@Test
@Ignore(
"java.lang.SecurityException: " +
"Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider" +
" requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs"
)
fun givenPickMediaIntent_whenPickMedia_thenImagePreviewContentIsShown() {
...
}
...
}
Describe alternatives you've considered
Tried Manual Testing API (CIVisibility + DDTest#setTag) only without javaagent, too much works to write all the RunListener on my own (similar to dd-java-agent JUnit4TracingListener).
Hey @flee-seekasia! Thanks a lot for the input. As you point out, currently it's not possible to set custom tags on skipped tests because they are never executed, so the test span is never active (we start and finish it immediately inside the same call).
Could you provide more information on what your use case would be for such a tag (is_ignored)? Even for ignored tests, marked with @Ignore, we already set test.status:skip and use the ignore reason as test.skip_reason. In your example, the givenPickMediaIntent_whenPickMedia_thenImagePreviewContentIsShown test should already be reported with:
test.status:skip
test.skip_reason: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIs
Activity
daniel-mohedano commentedon May 22, 2026
Hey @flee-seekasia! Thanks a lot for the input. As you point out, currently it's not possible to set custom tags on skipped tests because they are never executed, so the test span is never active (we start and finish it immediately inside the same call).
Could you provide more information on what your use case would be for such a tag (
is_ignored)? Even for ignored tests, marked with@Ignore, we already settest.status:skipand use the ignore reason astest.skip_reason. In your example, thegivenPickMediaIntent_whenPickMedia_thenImagePreviewContentIsShowntest should already be reported with:test.status:skiptest.skip_reason: java.lang.SecurityException: Permission Denial: opening provider com.android.providers.media.MediaDocumentsProvider requires that you obtain access using ACTION_OPEN_DOCUMENT or related APIsIs this not the case?