Repository navigation
Support test automation exclusion annotations in JUnit4 #12940
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
d3f712f
58b4eba
7d99f9c
ad876b0
4c3a3ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -45,6 +45,11 @@ TestSuiteImpl testSuiteStart( | |||||||||
| @Nullable | ||||||||||
| SkipReason skipReason(TestIdentifier test); | ||||||||||
|
|
||||||||||
| default SkipReason skipReason( | ||||||||||
| TestIdentifier test, TestSourceData source, Collection<String> tags) { | ||||||||||
| return skipReason(test); | ||||||||||
| } | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both Proxy and Headless already implement the method so we can make it abstract and also add back the
Suggested change
|
||||||||||
|
|
||||||||||
| @Nonnull | ||||||||||
| TestExecutionPolicy executionPolicy( | ||||||||||
| TestIdentifier test, TestSourceData testSource, Collection<String> testTags); | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -119,6 +119,12 @@ public boolean isAttemptToFix(TestIdentifier test) { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Nullable | ||||||||||||
| @Override | ||||||||||||
| public SkipReason skipReason( | ||||||||||||
| TestIdentifier test, TestSourceData source, Collection<String> tags) { | ||||||||||||
| return executionStrategy.skipReason(test, source, tags); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Override | ||||||||||||
| public SkipReason skipReason(TestIdentifier test) { | ||||||||||||
|
Comment on lines
128
to
129
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes moved over the
Suggested change
|
||||||||||||
| return executionStrategy.skipReason(test); | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -104,6 +104,12 @@ public boolean isAttemptToFix(TestIdentifier test) { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Nullable | ||||||||||||
| @Override | ||||||||||||
| public SkipReason skipReason( | ||||||||||||
| TestIdentifier test, TestSourceData source, Collection<String> tags) { | ||||||||||||
| return executionStrategy.skipReason(test, source, tags); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Override | ||||||||||||
| public SkipReason skipReason(TestIdentifier test) { | ||||||||||||
|
Comment on lines
113
to
114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as in Proxy
Suggested change
|
||||||||||||
| return executionStrategy.skipReason(test); | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||
| import datadog.trace.api.civisibility.CIConstants; | ||||||||||||
| import datadog.trace.api.civisibility.DDTest; | ||||||||||||
| import datadog.trace.api.civisibility.DDTestSuite; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestExclusions; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestIdentifier; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestSourceData; | ||||||||||||
| import datadog.trace.api.civisibility.events.TestEventsHandler; | ||||||||||||
|
|
@@ -24,6 +25,7 @@ | |||||||||||
| import datadog.trace.civisibility.domain.TestFrameworkSession; | ||||||||||||
| import datadog.trace.civisibility.domain.TestImpl; | ||||||||||||
| import datadog.trace.civisibility.domain.TestSuiteImpl; | ||||||||||||
| import datadog.trace.civisibility.execution.AttemptToFix; | ||||||||||||
| import java.util.Collection; | ||||||||||||
| import java.util.function.Supplier; | ||||||||||||
| import javax.annotation.Nonnull; | ||||||||||||
|
|
@@ -186,6 +188,13 @@ public void onTestStart( | |||||||||||
| TestImpl test = | ||||||||||||
| testSuite.testStart(testName, testParameters, testSourceData.getTestMethod(), startTime); | ||||||||||||
|
|
||||||||||||
| if (TestExclusions.noAutoRetry(testSourceData, categories)) { | ||||||||||||
| test.setTag("test.test_management.no_auto_retry", true); | ||||||||||||
| } | ||||||||||||
| if (TestExclusions.preventFailureSuppression(testSourceData, categories)) { | ||||||||||||
| test.setTag("test.test_management.prevent_failure_suppression", true); | ||||||||||||
| } | ||||||||||||
|
Comment on lines
+191
to
+196
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add both new tags to |
||||||||||||
|
|
||||||||||||
| TestIdentifier thisTest = test.getIdentifier(); | ||||||||||||
| if (testModule.isNew(thisTest)) { | ||||||||||||
| test.setTag(Tags.TEST_IS_NEW, true); | ||||||||||||
|
|
@@ -234,7 +243,7 @@ public void onTestStart( | |||||||||||
| test.setTag(Tags.TEST_ITR_UNSKIPPABLE, true); | ||||||||||||
| metricCollector.add(CiVisibilityCountMetric.ITR_UNSKIPPABLE, 1, EventType.TEST); | ||||||||||||
|
|
||||||||||||
| if (testModule.skipReason(thisTest) == SkipReason.ITR) { | ||||||||||||
| if (testModule.skipReason(thisTest, testSourceData, categories) == SkipReason.ITR) { | ||||||||||||
| test.setTag(Tags.TEST_ITR_FORCED_RUN, true); | ||||||||||||
| metricCollector.add(CiVisibilityCountMetric.ITR_FORCED_RUN, 1, EventType.TEST); | ||||||||||||
| } | ||||||||||||
|
|
@@ -303,7 +312,7 @@ public void onTestFinish( | |||||||||||
| test.setTag(Tags.TEST_HAS_FAILED_ALL_RETRIES, true); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (testModule.isAttemptToFix(test.getIdentifier())) { | ||||||||||||
| if (testExecutionTracker instanceof AttemptToFix) { | ||||||||||||
| test.setTag( | ||||||||||||
| Tags.TEST_TEST_MANAGEMENT_ATTEMPT_TO_FIX_PASSED, | ||||||||||||
| outcome.aggregation() == ExecutionAggregation.ONLY_PASSED); | ||||||||||||
|
|
@@ -356,6 +365,12 @@ public int executionPriority(@Nullable TestIdentifier test, @Nonnull TestSourceD | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Nullable | ||||||||||||
| @Override | ||||||||||||
| public SkipReason skipReason( | ||||||||||||
| TestIdentifier test, TestSourceData source, Collection<String> tags) { | ||||||||||||
| return getOrCreateTestModule().skipReason(test, source, tags); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Override | ||||||||||||
| public SkipReason skipReason(TestIdentifier test) { | ||||||||||||
|
Comment on lines
374
to
375
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The override is missing the
Suggested change
|
||||||||||||
| return getOrCreateTestModule().skipReason(test); | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||
|
|
||||||||||||
| import datadog.trace.api.Config; | ||||||||||||
| import datadog.trace.api.civisibility.CIConstants; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestExclusions; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestIdentifier; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestMetadata; | ||||||||||||
| import datadog.trace.api.civisibility.config.TestSourceData; | ||||||||||||
|
|
@@ -21,6 +22,7 @@ | |||||||||||
| import datadog.trace.civisibility.source.SourcePathResolver; | ||||||||||||
| import java.lang.reflect.Method; | ||||||||||||
| import java.util.Collection; | ||||||||||||
| import java.util.Collections; | ||||||||||||
| import java.util.Map; | ||||||||||||
| import java.util.concurrent.atomic.AtomicInteger; | ||||||||||||
| import javax.annotation.Nonnull; | ||||||||||||
|
|
@@ -91,16 +93,21 @@ public boolean isAttemptToFix(TestIdentifier test) { | |||||||||||
|
|
||||||||||||
| @Nullable | ||||||||||||
| public SkipReason skipReason(TestIdentifier test) { | ||||||||||||
| return skipReason(test, TestSourceData.UNKNOWN, Collections.emptyList()); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| public SkipReason skipReason( | ||||||||||||
|
Comment on lines
+98
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| TestIdentifier test, TestSourceData source, Collection<String> tags) { | ||||||||||||
| if (test == null) { | ||||||||||||
| return null; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| // test should not be skipped if it is an attempt to fix, independent of TIA or Disabled | ||||||||||||
| if (isAttemptToFix(test)) { | ||||||||||||
| if (isAttemptToFix(test) && !TestExclusions.noAutoRetry(source, tags)) { | ||||||||||||
| return null; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (isDisabled(test)) { | ||||||||||||
| if (isDisabled(test) && !TestExclusions.preventFailureSuppression(source, tags)) { | ||||||||||||
|
calvinbayer marked this conversation as resolved.
|
||||||||||||
| return SkipReason.DISABLED; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
@@ -126,34 +133,35 @@ public TestExecutionPolicy executionPolicy( | |||||||||||
| return Regular.INSTANCE; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (isAttemptToFix(test)) { | ||||||||||||
| boolean noAutoRetry = TestExclusions.noAutoRetry(testSource, testTags); | ||||||||||||
| boolean quarantined = | ||||||||||||
| isQuarantined(test) && !TestExclusions.preventFailureSuppression(testSource, testTags); | ||||||||||||
| if (isAttemptToFix(test) && !noAutoRetry) { | ||||||||||||
| return new AttemptToFix( | ||||||||||||
| executionSettings.getTestManagementSettings().getAttemptToFixRetries()); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (isEFDApplicable(test, testSource, testTags)) { | ||||||||||||
| if (!noAutoRetry && isEFDApplicable(test, testSource, testTags)) { | ||||||||||||
| // check-then-act with "earlyFlakeDetectionsUsed" is not atomic here, | ||||||||||||
| // but we don't care if we go "a bit" over the limit, it does not have to be precise | ||||||||||||
| earlyFlakeDetectionsUsed.incrementAndGet(); | ||||||||||||
| return new EarlyFlakeDetection( | ||||||||||||
| executionSettings.getEarlyFlakeDetectionSettings().getExecutionsByDuration(), | ||||||||||||
| isQuarantined(test)); | ||||||||||||
| quarantined); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (isAutoRetryApplicable(test)) { | ||||||||||||
| if (!noAutoRetry && isAutoRetryApplicable(test)) { | ||||||||||||
| // check-then-act with "autoRetriesUsed" is not atomic here, | ||||||||||||
| // but we don't care if we go "a bit" over the limit, it does not have to be precise | ||||||||||||
| if (executionSettings.getDynamicAutoTestRetrySettings().isEnabled()) { | ||||||||||||
| return new DynamicAutoTestRetry( | ||||||||||||
| executionSettings.getDynamicAutoTestRetrySettings(), | ||||||||||||
| isQuarantined(test), | ||||||||||||
| autoRetriesUsed); | ||||||||||||
| executionSettings.getDynamicAutoTestRetrySettings(), quarantined, autoRetriesUsed); | ||||||||||||
| } | ||||||||||||
| return new AutoTestRetry( | ||||||||||||
| config.getCiVisibilityFlakyRetryCount(), isQuarantined(test), autoRetriesUsed); | ||||||||||||
| config.getCiVisibilityFlakyRetryCount(), quarantined, autoRetriesUsed); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| if (isQuarantined(test)) { | ||||||||||||
| if (quarantined) { | ||||||||||||
| return new Quarantine(); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 suggestion: Can you group it under the
# @DataDog/ci-app-librariessection?