Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import datadog.trace.instrumentation.junit4.MUnitUtils
import datadog.trace.instrumentation.junit4.TestEventsHandlerHolder
import org.example.TestFailedAssumptionMUnit
import org.example.TestFailedMUnit
import org.example.TestAutomationExcluded
import org.example.TestFailedThenSucceedMUnit
import org.example.TestSkippedMUnit
import org.example.TestSkippedSuiteMUnit
Expand All @@ -21,6 +22,38 @@ class MUnitTest extends CiVisibilityInstrumentationTest {

def runner = new JUnitCore()

def "test automation exclusions preserve a blocking failure and execute once"() {
given:
def id = new TestFQN("org.example.TestAutomationExcluded", "protected_failure")
givenDisabledTests([id])
givenQuarantinedTests([id])
givenAttemptToFixTests([id])
givenFlakyRetryEnabled(true)
givenFlakyTests([id])
givenEarlyFlakinessDetectionEnabled(true)
givenKnownTests([])

when:
runTests([TestAutomationExcluded], false)

then:
TEST_WRITER.toList().flatten().count { it.getTag("test.name") == "protected_failure" } == 1
def testSpan = TEST_WRITER.toList().flatten().find { it.getTag("test.name") == "protected_failure" }
testSpan != null
testSpan.getTag("test.test_management.no_auto_retry") == true
testSpan.getTag("test.test_management.prevent_failure_suppression") == true
testSpan.getTag("test.test_management.is_test_disabled") == true
testSpan.getTag("test.test_management.is_quarantined") == true
testSpan.getTag("test.test_management.is_attempt_to_fix") == true
testSpan.getTag("test.test_management.attempt_to_fix_passed") == null
def skippedSpan = TEST_WRITER.toList().flatten().find { it.getTag("test.name") == "protected_skip" }
skippedSpan != null
skippedSpan.getTag("test.test_management.no_auto_retry") == true
skippedSpan.getTag("test.test_management.prevent_failure_suppression") == true
skippedSpan.getTag("test.status").toString() == "skip"
}


def "test #testcaseName"() {
runTests(tests)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.example

import datadog.trace.api.civisibility.TestAutomationExclusions
import munit.FunSuite

class TestAutomationExcluded extends FunSuite {
private val noRetry = new munit.Tag(TestAutomationExclusions.NO_AUTO_RETRY)
private val preventSuppression =
new munit.Tag(TestAutomationExclusions.PREVENT_FAILURE_SUPPRESSION)

test("protected_failure".tag(noRetry).tag(preventSuppression)) {
assert(false)
}

test("protected_skip".tag(noRetry).tag(preventSuppression).ignore) {
assert(false)
}
}
18 changes: 18 additions & 0 deletions docs/test-automation-exclusions.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,21 @@ scenario tags before Datadog skipping and retry policy selection.
Declare ScalaTest `Tag` instances from `TestAutomationExclusions.NO_AUTO_RETRY`
and `PREVENT_FAILURE_SUPPRESSION`, then pass them to the test declaration.
Native ignored tests remain ignored and carry their known exclusion tags.

## MUnit

Apply native MUnit tags using the public constants:

```scala
import datadog.trace.api.civisibility.TestAutomationExclusions

test("critical behavior"
.tag(new munit.Tag(TestAutomationExclusions.NO_AUTO_RETRY))
.tag(new munit.Tag(TestAutomationExclusions.PREVENT_FAILURE_SUPPRESSION))) {
assert(false)
}
```

MUnit's existing category bridge passes these declarations to the shared policy
and reporter. Ignored tests retain their known tags. MUnit currently has no
Datadog disabling capability; exclusions do not enable unsupported automation.
Loading