{"record":{"id":"d36cd4a2082a8f6e","repo":"dotnet/maui","slug":"at-least-failed-test-s-failed-in-system-io-pat","errorCode":null,"errorMessage":"At least {failed} test(s) failed in {System.IO.Path.GetFileName(file)}.","messagePattern":"At least (.+?) test\\(s\\) failed in (.+?)\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/windows.cake","lineNumber":645,"sourceCode":"\t// Check if we have any test result files at all\n\tvar actualResultFiles = System.IO.Directory.GetFiles(testResultsPath, \"TestResults-*.xml\");\n\tif (actualResultFiles.Length == 0)\n\t{\n\t\tthrow new Exception($\"No test result files found. All test processes may have crashed or failed to start.\");\n\t}\n\n\t// If we're running Controls tests, validate we have results for expected categories\n\tif (isControlsProjectTestRun && failedCategories.Any())\n\t{\n\t\tthrow new Exception($\"Some test categories failed to complete: {string.Join(\", \", failedCategories)}. Expected {completedCategories.Count + failedCategories.Count} categories, but {failedCategories.Count} failed.\");\n\t}\n\n\t// Check for test failures in the result files\n\tforeach(var file in actualResultFiles)\n\t{\n\t\tvar failed = XmlPeek(file, \"/assemblies/assembly[@failed > 0 or @errors > 0]/@failed\");\n\t\tif (!string.IsNullOrEmpty(failed)) {\n\t\t\tthrow new Exception($\"At least {failed} test(s) failed in {System.IO.Path.GetFileName(file)}.\");\n\t\t}\n\t}\n\n\tInformation($\"✓ All test executions completed successfully with {actualResultFiles.Length} result file(s)\");\n});\n\nTask(\"build\")\n\t.IsDependentOn(\"buildOnly\");\n\nTask(\"test\")\n\t.IsDependentOn(\"buildOnly\")\n\t.IsDependentOn(\"testOnly\");\n\nTask(\"buildAndTest\")\n\t.IsDependentOn(\"buildOnly\")\n\t.IsDependentOn(\"testOnly\");\n\nTask(\"SetupTestPaths\")","sourceCodeStart":627,"sourceCodeEnd":663,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/windows.cake#L627-L663","documentation":"Thrown during result-file inspection when XmlPeek finds an /assemblies/assembly element with @failed > 0 or @errors > 0 — i.e. the xUnit-style result XML reports actual test failures or errors. This is the only throw in the file that represents genuine test failures (assertions/errors) rather than infrastructure problems; the file name and failure count are included.","triggerScenarios":"A test assertion failed within a category; a test threw an unhandled exception (counted as an error); the test runner recorded failures in the assembly-level summary attributes of a TestResults-*.xml file.","commonSituations":"A real regression causing test failures; an environment-dependent test failing on a specific OS/build; flaky tests; a dependency change breaking assertions. This throw is expected whenever tests legitimately fail — it is not an infrastructure defect.","solutions":["Open the named TestResults-*.xml file to see which specific tests failed and their error messages/stack traces.","Reproduce the failing tests locally with the same --test-filter/category to debug.","If the failures are a known regression, fix the code; if flaky, mark them for retry/quarantine per the repo's policy.","Confirm the @failed/@errors attributes are not inflated by a runner reporting setup errors as test failures (check for a single error in a setup method)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Optionally, treat known-flaky failures as non-fatal by checking against a quarantine list before throwing\nvar failed = XmlPeek(file, \"/assemblies/assembly[@failed > 0 or @errors > 0]/@failed\");\nif (!string.IsNullOrEmpty(failed) && !IsQuarantined(System.IO.Path.GetFileName(file)))\n    throw new Exception($\"{failed} test(s) failed in {System.IO.Path.GetFileName(file)}.\");","typeGuard":null,"tryCatchPattern":"try { /* run tests */ }\ncatch (Exception ex) when (ex.Message.Contains(\"test(s) failed\"))\n{\n    // Expected when tests genuinely fail — archive results, surface failure list, rethrow or mark unstable\n    Information($\"Test failures detected: {ex.Message}\");\n    throw;\n}","preventionTips":["Open the named TestResults XML to see the specific failing tests and stack traces.","Reproduce failures locally with the same category filter before fixing.","Use the repo's quarantine/retry policy for flaky tests rather than disabling the check."],"tags":["cake","windows","test-results","xunit","assertion-failure","device-tests"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}