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 @@ -11,6 +11,7 @@
import datadog.trace.api.Config;
import datadog.trace.api.civisibility.CIConstants;
import datadog.trace.api.civisibility.config.TestIdentifier;
import datadog.trace.api.civisibility.config.TestSourceData;
import datadog.trace.api.civisibility.telemetry.tag.SkipReason;
import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
Expand Down Expand Up @@ -85,7 +86,7 @@ public static Boolean run(
SkipReason skipReason =
TestEventsHandlerHolder.HANDLERS
.get(TestFrameworkInstrumentation.CUCUMBER)
.skipReason(test);
.skipReason(test, TestSourceData.UNKNOWN, CucumberUtils.getCategories(pickle));
if (skipReason == null) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,33 @@ class CucumberTest extends CiVisibilityInstrumentationTest {

def runner = new JUnitCore()

def "test automation exclusions keep a protected scenario blocking and execute once"() {
given:
def path = "org/example/cucumber/calculator/automation_excluded.feature"
def id = new TestFQN("classpath:${path}:Basic Arithmetic", "Addition")
givenDisabledTests([id])
givenQuarantinedTests([id])
givenAttemptToFixTests([id])
givenFlakyRetryEnabled(true)
givenFlakyTests([id])
givenEarlyFlakinessDetectionEnabled(true)
givenKnownTests([])

when:
runFeatures([path], false)

then:
def testSpans = TEST_WRITER.toList().flatten().findAll { it.getTag("test.name") == "Addition" }
testSpans.size() == 1
def testSpan = testSpans.first()
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 "test #testcaseName"() {
runFeatures(features, success)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@datadog_no_auto_retry @datadog_prevent_failure_suppression
Feature: Basic Arithmetic

Background: A Calculator
Given a calculator I just turned on

Scenario: Addition
# Try to change one of the values below to provoke a failure
When I add 4 and 5
Then the result is 42
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import datadog.trace.api.Config;
import datadog.trace.api.civisibility.CIConstants;
import datadog.trace.api.civisibility.config.TestIdentifier;
import datadog.trace.api.civisibility.config.TestSourceData;
import datadog.trace.api.civisibility.events.TestEventsHandler;
import datadog.trace.api.civisibility.telemetry.tag.SkipReason;
import datadog.trace.api.civisibility.telemetry.tag.TestFrameworkInstrumentation;
Expand Down Expand Up @@ -109,7 +110,9 @@ public static void shouldBeSkipped(
return;
}

SkipReason skipReason = testEventsHandler.skipReason(test);
SkipReason skipReason =
testEventsHandler.skipReason(
test, TestSourceData.UNKNOWN, JUnitPlatformUtils.getTags(testDescriptor));
if (skipReason == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,33 @@ import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass
@DisableTestTrace(reason = "avoid self-tracing")
class CucumberTest extends CiVisibilityInstrumentationTest {

def "test automation exclusions keep a protected scenario blocking and execute once"() {
given:
def path = "org/example/cucumber/calculator/automation_excluded.feature"
def id = new TestFQN("classpath:${path}:Basic Arithmetic", "Addition")
givenDisabledTests([id])
givenQuarantinedTests([id])
givenAttemptToFixTests([id])
givenFlakyRetryEnabled(true)
givenFlakyTests([id])
givenEarlyFlakinessDetectionEnabled(true)
givenKnownTests([])

when:
runFeatures([path], false, false)

then:
def testSpans = TEST_WRITER.toList().flatten().findAll { it.getTag("test.name") == "Addition" }
testSpans.size() == 1
def testSpan = testSpans.first()
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 "test #testcaseName"() {
runFeatures(features, parallel)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@datadog_no_auto_retry @datadog_prevent_failure_suppression
Feature: Basic Arithmetic

Background: A Calculator
Given a calculator I just turned on

Scenario: Addition
When I add 4 and 5
Then the result is 45
7 changes: 7 additions & 0 deletions docs/test-automation-exclusions.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ constants. User-supplied retry analyzers retain their existing behavior.
Apply the public annotations directly to a Spock feature method. They apply
to every data-driven iteration. Spec-level skip aggregation inspects the
feature declaration before deciding whether the whole spec can be skipped.

## Cucumber

For either the JUnit4 or JUnit Platform Cucumber runner, tag a Scenario or
Scenario Outline with `@datadog_no_auto_retry` and/or
`@datadog_prevent_failure_suppression`. These names correspond to the public
`TestAutomationExclusions` constants. Tags apply to every outline example.
Loading