{"record":{"id":"50efb3fa5463fdd6","repo":"dotnet/maui","slug":"could-not-find-total-or-inconclusive-test-count-in","errorCode":null,"errorMessage":"Could not find total or inconclusive test count in test results.","messagePattern":"Could not find total or inconclusive test count in test results\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/devices-shared.cake","lineNumber":148,"sourceCode":"    return GetDirectories($\"{directory}/*.app\").Select(dir => dir.FullPath);\n}\n\nIEnumerable<string> FindApksInDirectory(DirectoryPath directory)\n{\n    Information($\"Looking for .apk files in {directory}\");\n    return GetFiles($\"{directory}/*-Signed.apk\").Select(file => file.FullPath);\n}\n\n\nvoid FailRunOnOnlyInconclusiveTests(string testResultsFile)\n{\n    // When all tests are inconclusive the run does not fail, check if this is the case and fail the pipeline so we get notified\n    var totalTestCount = XmlPeek(testResultsFile, \"/assemblies/assembly/@total\");\n    var inconclusiveTestCount = XmlPeek(testResultsFile, \"/assemblies/assembly/@inconclusive\");\n\n    if (totalTestCount == null)\n    {\n        throw new Exception(\"Could not find total or inconclusive test count in test results.\");\n    }\n    if (totalTestCount.Equals(inconclusiveTestCount))\n    {\n        throw new Exception(\"All tests are marked inconclusive, no tests ran. There is probably something wrong with running the tests.\");\n    }\n}\n\nvoid CleanResults(string resultsDir)\n{\n    Information($\"Cleaning test results: {resultsDir}\");\n\n    if (!IsCIBuild())\n    {\n        CleanDirectories(resultsDir);\n    }\n    else\n    {\n        // Because we retry on CI we don't want to delete the previous failures","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/devices-shared.cake#L130-L166","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm testResultsFile exists and is a complete xUnit-format XML with an <assemblies><assembly total=\"...\"> root.","If using a different runner, configure it to emit xUnit XML, or adapt the XPath to the actual schema.","Re-run the tests to regenerate a valid results file before this guard runs.","Check for truncation/encoding issues (BOM, partial write) if the file exists but peek fails."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!FileExists(testResultsFile))\n    throw new Exception($\"Test results file not found: {testResultsFile}\");\nvar total = XmlPeek(testResultsFile, \"/assemblies/assembly/@total\");\nif (total == null)\n    throw new Exception($\"'{testResultsFile}' is missing /assemblies/assembly/@total — not xUnit XML or incomplete.\");","typeGuard":"bool IsXUnitResultsXml(string file) {\n    if (!FileExists(file)) return false;\n    return XmlPeek(file, \"name(/assemblies/assembly)\") != null;\n}","tryCatchPattern":null,"preventionTips":["Configure the runner to emit xUnit XML format consistently.","Verify the results file exists and is non-empty before peeking.","Guard against concurrent/truncated writes by checking file completeness."],"tags":["test-results","xml","xunit","validation","xmlpeek"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}