{"record":{"id":"c80c28031f0f429a","repo":"dotnet/maui","slug":"no-test-results-found","errorCode":null,"errorMessage":"No test results found.","messagePattern":"No test results found\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"eng/devices/devices-shared.cake","lineNumber":247,"sourceCode":"\t\t{\n\t\t\tvalues.Add($\"Category={(string)field.GetValue(null)}\");\n\t\t}\n\t}\n\t\n\treturn values.ToList();\n}\n\nvoid HandleTestResults(string resultsDir, bool testsFailed, bool needsNameFix, string suffix = null)\n{\n    Information($\"Handling test results: {resultsDir}\");\n\n    // catalyst and ios test result files are weirdly named, so fix it up\n    if(needsNameFix)\n    {\n        var resultsFile = GetFiles($\"{resultsDir}/xunit-test-*.xml\").FirstOrDefault();\n        if (resultsFile == null)\n        {\n            throw new Exception(\"No test results found.\");\n        }\n        \n        if (FileExists(resultsFile))\n        {\n            Information($\"Test results found on {resultsDir}\");\n            MoveFile(resultsFile, resultsFile.GetDirectory().CombineWithFilePath($\"testResults{suffix}.xml\"));\n            var logFiles = GetFiles($\"{resultsDir}/*.log\");\n\n            foreach (var logFile in logFiles)\n            {\n                if (logFile.GetFilename().ToString().StartsWith(\"testResults\"))\n                {\n                    // These are log files that have already been renamed\n                    continue;\n                }\n\n                Information($\"Log file found: {logFile.GetFilename().ToString()}\");\n                MoveFile(logFile, resultsFile.GetDirectory().CombineWithFilePath($\"testResults{suffix}-{logFile.GetFilename()}\"));","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/eng/devices/devices-shared.cake#L229-L265","documentation":"Thrown inside HandleTestResults when needsNameFix is true (iOS/catalyst runs) and GetFiles for xunit-test-*.xml in the results directory yields no match. XHarness writes its xUnit XML to a file named xunit-test-<timestamp>.xml; absence means the test runner never reached the result-writing stage.","triggerScenarios":"Calling HandleTestResults after an iOS/catalyst xharness run that crashed, timed out, or was killed before emitting results; passing a resultsDir that points at the wrong folder; the runner writing to a sibling directory because --output-directory was set differently; a prior step deleting the results dir.","commonSituations":"Simulator boot failure causing xharness to exit before tests start; app install failure on the simulator; a stale results dir from a previous run that was partially cleaned; CI reruns where the results dir path changed between matrix legs.","solutions":["Inspect the *.log files and xharness stdout in resultsDir for the real failure (boot timeout, install error, crash) — the missing XML is a symptom, not the cause.","Verify resultsDir matches the --output-directory passed to xharness apple test; mismatched paths are the most common cause.","Re-run with a clean results dir to rule out a leftover file with a different name pattern from a previous run.","Increase the xharness --launch-timeout if logs show the app started but never finished writing results."],"exampleFix":"// before\nvar resultsFile = GetFiles($\"{resultsDir}/xunit-test-*.xml\").FirstOrDefault();\nif (resultsFile == null)\n    throw new Exception(\"No test results found.\");\n\n// after: surface what *is* in the dir so the failure is diagnosable\nvar resultsFile = GetFiles($\"{resultsDir}/xunit-test-*.xml\").FirstOrDefault();\nif (resultsFile == null)\n{\n    var contents = string.Join(\", \", GetFiles($\"{resultsDir}/*\").Select(f => f.GetFilename().ToString()));\n    throw new Exception($\"No test results found in {resultsDir}. Contents: {contents}\");\n}","handlingStrategy":"validation","validationCode":"// Before HandleTestResults, confirm xharness wrote output\nvar candidate = GetFiles($\"{resultsDir}/xunit-test-*.xml\");\nif (needsNameFix && (candidate == null || !candidate.Any()))\n{\n    var dump = string.Join(\", \", GetFiles($\"{resultsDir}/*\").Select(f => f.GetFilename().ToString()));\n    throw new Exception($\"XHarness produced no results in {resultsDir}. Dir contents: {dump}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep resultsDir identical to the --output-directory passed to xharness.","Archive the full results dir (logs included) in CI so missing-XML failures are diagnosable.","Clean the results dir before each run to avoid confusing stale files with fresh output."],"tags":["cake","test-results","xharness","ios","device-tests"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}