dotnet/maui · error · Exception
At least {failed} test(s) failed in {System.IO.Path.GetFileN
Error message
At least {failed} test(s) failed in {System.IO.Path.GetFileName(file)}. What it means
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.
Source
Thrown at eng/devices/windows.cake:645
// Check if we have any test result files at all
var actualResultFiles = System.IO.Directory.GetFiles(testResultsPath, "TestResults-*.xml");
if (actualResultFiles.Length == 0)
{
throw new Exception($"No test result files found. All test processes may have crashed or failed to start.");
}
// If we're running Controls tests, validate we have results for expected categories
if (isControlsProjectTestRun && failedCategories.Any())
{
throw new Exception($"Some test categories failed to complete: {string.Join(", ", failedCategories)}. Expected {completedCategories.Count + failedCategories.Count} categories, but {failedCategories.Count} failed.");
}
// Check for test failures in the result files
foreach(var file in actualResultFiles)
{
var failed = XmlPeek(file, "/assemblies/assembly[@failed > 0 or @errors > 0]/@failed");
if (!string.IsNullOrEmpty(failed)) {
throw new Exception($"At least {failed} test(s) failed in {System.IO.Path.GetFileName(file)}.");
}
}
Information($"✓ All test executions completed successfully with {actualResultFiles.Length} result file(s)");
});
Task("build")
.IsDependentOn("buildOnly");
Task("test")
.IsDependentOn("buildOnly")
.IsDependentOn("testOnly");
Task("buildAndTest")
.IsDependentOn("buildOnly")
.IsDependentOn("testOnly");
Task("SetupTestPaths")View on GitHub (pinned to f377ff1c5e)
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).
Defensive patterns
Strategy: try-catch
Validate before calling
// Optionally, treat known-flaky failures as non-fatal by checking against a quarantine list before throwing
var failed = XmlPeek(file, "/assemblies/assembly[@failed > 0 or @errors > 0]/@failed");
if (!string.IsNullOrEmpty(failed) && !IsQuarantined(System.IO.Path.GetFileName(file)))
throw new Exception($"{failed} test(s) failed in {System.IO.Path.GetFileName(file)}."); Try / catch
try { /* run tests */ }
catch (Exception ex) when (ex.Message.Contains("test(s) failed"))
{
// Expected when tests genuinely fail — archive results, surface failure list, rethrow or mark unstable
Information($"Test failures detected: {ex.Message}");
throw;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No test result files found. All test processes may have cras
- Some test categories failed to complete: {string.Join(", ",
- No test results found.
- Could not find total or inconclusive test count in test resu
- All tests are marked inconclusive, no tests ran. There is pr
AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13).
Data as JSON: /api/errors/d36cd4a2082a8f6e.
Report an issue: GitHub.