dotnet/maui · error · Exception

Could not find total or inconclusive test count in test resu

Error message

Could not find total or inconclusive test count in test results.

What it means

Thrown by FailRunOnOnlyInconclusiveTests when XmlPeek for the '/assemblies/assembly/@total' attribute on the test results file returns null. The function relies on xUnit-style XML results; if the total attribute (or the file/structure) is absent, it cannot determine whether the run was real.

Source

Thrown at eng/devices/devices-shared.cake:148

    return GetDirectories($"{directory}/*.app").Select(dir => dir.FullPath);
}

IEnumerable<string> FindApksInDirectory(DirectoryPath directory)
{
    Information($"Looking for .apk files in {directory}");
    return GetFiles($"{directory}/*-Signed.apk").Select(file => file.FullPath);
}


void FailRunOnOnlyInconclusiveTests(string testResultsFile)
{
    // When all tests are inconclusive the run does not fail, check if this is the case and fail the pipeline so we get notified
    var totalTestCount = XmlPeek(testResultsFile, "/assemblies/assembly/@total");
    var inconclusiveTestCount = XmlPeek(testResultsFile, "/assemblies/assembly/@inconclusive");

    if (totalTestCount == null)
    {
        throw new Exception("Could not find total or inconclusive test count in test results.");
    }
    if (totalTestCount.Equals(inconclusiveTestCount))
    {
        throw new Exception("All tests are marked inconclusive, no tests ran. There is probably something wrong with running the tests.");
    }
}

void CleanResults(string resultsDir)
{
    Information($"Cleaning test results: {resultsDir}");

    if (!IsCIBuild())
    {
        CleanDirectories(resultsDir);
    }
    else
    {
        // Because we retry on CI we don't want to delete the previous failures

View on GitHub (pinned to f377ff1c5e)

Solutions

  1. Confirm testResultsFile exists and is a complete xUnit-format XML with an <assemblies><assembly total="..."> root.
  2. If using a different runner, configure it to emit xUnit XML, or adapt the XPath to the actual schema.
  3. Re-run the tests to regenerate a valid results file before this guard runs.
  4. Check for truncation/encoding issues (BOM, partial write) if the file exists but peek fails.
Defensive patterns

Strategy: validation

Validate before calling

if (!FileExists(testResultsFile))
    throw new Exception($"Test results file not found: {testResultsFile}");
var total = XmlPeek(testResultsFile, "/assemblies/assembly/@total");
if (total == null)
    throw new Exception($"'{testResultsFile}' is missing /assemblies/assembly/@total — not xUnit XML or incomplete.");

Type guard

bool IsXUnitResultsXml(string file) {
    if (!FileExists(file)) return false;
    return XmlPeek(file, "name(/assemblies/assembly)") != null;
}

Prevention

When it happens

Trigger: XmlPeek(testResultsFile, "/assemblies/assembly/@total") returns null — the results file is missing, empty, not XML, or uses a schema without an /assemblies/assembly/@total attribute.

Common situations: The test results path points at a non-existent or incompletely-written file; the runner emitted TRX (VSTest) instead of xUnit XML; the file is from a different test framework; a concurrent write left the XML malformed.

Related errors


AI-assisted analysis of dotnet/maui@f377ff1c5e (2026-08-13). Data as JSON: /api/errors/50efb3fa5463fdd6. Report an issue: GitHub.