Unity Test Runner and CI pipeline: new-failure alert deduplication
0 reputation · 09 Feb 2022, 02:23 UTC
0 reputation · 09 Feb 2022, 02:23 UTC
Route Unity Test Runner batch failures to CI alerts so only newly failing or regressed tests generate notifications, while repeated notices for pre-existing or flaky failures are suppressed.
The Unity Editor Test Runner and com.unity.test.framework emit NUnit-style result XML and a nonzero exit code, but no built-in baseline, known-issue, or flaky-test suppression marker is visible in the runner output. The local Test Runner UI cannot send email, chat, or issue-tracker notifications, so deduplication must occur in an external CI/CD system or custom script. Behavior may vary by Unity LTS release and package version, and PlayMode results can be nondeterministic because of timing or asset loading.
Can result XML from successive runs be compared to isolate only newly failing tests without a built-in suppression field? Does any supported Unity version or package version expose known-issue or flaky-test tagging? Should flaky PlayMode failures be suppressed entirely, or only after a defined pass threshold?
36775 reputation · 09 Feb 2022, 13:41 UTC
Yes, you can isolate newly failing tests by comparing NUnit-style XML outputs from successive Unity Test Runner batches. No built-in "known-issue" or "flaky" marker exists in the runner output, so deduplication must be implemented in your CI/CD pipeline or a custom post-processing script.
com.unity.test.framework) emits NUnit XML per batch run, including each test case's full name (class + method), pass/fail status, and assertion details. The process exits with a non-zero code if any test fails.test-results.xml) as a pipeline artifact.import xml.etree.ElementTree as ET
import sys
def failed_names(xml_path):
tree = ET.parse(xml_path)
root = tree.getroot()
# NUnit v3 uses ; v2 uses ; adjust XPath as needed
return {tc.attrib['name'] for tc in root.iter('test-case') if tc.attrib.get('result') == 'Failed'}
current = failed_names(sys.argv[1])
baseline = failed_names(sys.argv[2])
new_failures = current - baseline
print('\n'.join(sorted(new_failures)))
new_failures. If the set is empty, suppress the notification; otherwise, send the list to your chat/email/issue tracker.-batchmode -runTests -testResults results1.xml and results2.xml.[Category("Flaky")] NUnit attribute to a test, re-run, and verify the attribute appears in the XML (it will appear as a property child of test-case in newer schemas). This proves you can later filter by category if you adopt a tagging convention.Which CI system are you using (GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, etc.)? The artifact storage, caching, and notification mechanisms differ enough that the concrete implementation (e.g., using actions/upload-artifact vs. Jenkins archiveArtifacts) depends on this choice.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.