{"record":{"id":"7617212afb9aaf73","repo":"ThreeMammals/Ocelot","slug":"no-coverage-cobertura-xml-files-found-in","errorCode":null,"errorMessage":"No coverage.cobertura.*.xml files found in {artifactsForUnitTestsDir}","messagePattern":"No coverage\\.cobertura\\.\\*\\.xml files found in (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"build.cake","lineNumber":595,"sourceCode":"\t\t\t\t\t\t\t$\"--coverlet-exclude \\\"[Ocelot.Testing]*\\\"\",\r\n\t\t\t\tWorkingDirectory = \".\"\r\n\t\t\t});\r\n\t\t\t// Only fail on actual test failures, not on thread exit issues\r\n\t\t\tif (exitCode != 0 && exitCode != 7)\r\n\t\t\t{\r\n\t\t\t\tthrow new Exception($\"dotnet test failed with exit code {exitCode}\");\r\n\t\t\t}\r\n\t\t\telse if (exitCode == 7)\r\n\t\t\t{\r\n\t\t\t\tWarning(\"Tests passed but background threads didn't exit cleanly (exit code 7). Ignoring.\");\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\tInformation(\"ArtifactsForUnitTestsDir = \" + artifactsForUnitTestsDir);\r\n\t\t// Find all files matching pattern \"coverage.cobertura.*.xml\"\r\n\t\tvar coverageFiles = GetFiles(artifactsForUnitTestsDir.ToString() + \"/coverage.cobertura.*.xml\");\r\n\t\tif (!coverageFiles.Any())\r\n\t\t\tthrow new Exception($\"No coverage.cobertura.*.xml files found in {artifactsForUnitTestsDir}\");\r\n\t\t// Get the first matching file (or order by creation date if needed)\r\n\t\tvar coverageSummaryFile = coverageFiles.First();\r\n\t\tInformation(\"CoverageSummaryFile = \" + coverageSummaryFile);\r\n\t\tGenerateReport(coverageSummaryFile);\r\n\t\tInformation(\"##############################\");\r\n\t\tInformation(\"# Code coverage\");\r\n\t\tInformation(\"#=============================\");\r\n\r\n\t\t// TODO Implement reporting to the Action Run summary as an attachment or artifact\r\n\t\tconst string CoverallsRepo = \"https://coveralls.io/github/ThreeMammals/Ocelot\";\r\n\t\tInformation($\"# There is dedicated Coveralls step of GH Action workflows. So, we won't publish the coverage report to coveralls.io\");\r\n\r\n\t\t// Apply code coverage threshold\r\n\t\tconst double MinCodeCoverage = 0.93D; // consider definition of an env var in GitHub Environment vars\r\n\t\tvar lineCoverage = XmlPeek(coverageSummaryFile, \"//coverage/@line-rate\");\r\n\t\tvar branchCoverage = XmlPeek(coverageSummaryFile, \"//coverage/@branch-rate\");\r\n\t\tInformation(\"# Line Coverage: \" + lineCoverage);\r\n\t\tInformation(\"# Branch Coverage: \" + branchCoverage);\r","sourceCodeStart":577,"sourceCodeEnd":613,"githubUrl":"https://github.com/ThreeMammals/Ocelot/blob/d1f22d930430410bfd0233f5e9e4f92980cf7df0/build.cake#L577-L613","documentation":"After unit tests run with the coverlet collector, the build expects at least one 'coverage.cobertura.*.xml' report in the unit-test artifacts directory. If GetFiles finds none, this error aborts the coverage reporting step. It means coverage data was never generated or was written elsewhere.","triggerScenarios":"Tests did not actually run or produce coverage (test run skipped/failed earlier); coverlet collector not enabled via --collect:\"XPlat Code Coverage\"; output path differs from artifactsForUnitTestsDir; glob case/path mismatch.","commonSituations":"Running coverage task without the test task; coverlet.collector package missing from test projects; coverage output redirected to a custom directory; stale artifacts folder cleaned before the check.","solutions":["Check the logged 'ArtifactsForUnitTestsDir = ...' path and verify coverage.cobertura*.xml exists there manually.","Ensure the dotnet test invocation includes --collect:\"XPlat Code Coverage\" and the coverlet.collector package.","Confirm the test run succeeded before the coverage step (fix the earlier failing task first).","Align the artifacts directory used by the test task and the coverage glob.","Verify case-sensitivity of the directory path on Linux CI agents."],"exampleFix":"// before\nGetFiles(artifactsForUnitTestsDir.ToString() + \"/coverage.cobertura.*.xml\");\n// after\nGetFiles(artifactsForUnitTestsDir.ToString() + \"/**/coverage.cobertura*.xml\");","handlingStrategy":"validation","validationCode":"var coverageFiles = GetFiles(artifactsForUnitTestsDir + \"/coverage.cobertura.*.xml\");\nif (!coverageFiles.Any()) throw new Exception($\"No coverage files in {artifactsForUnitTestsDir} — did the test task run with coverlet?\");","typeGuard":null,"tryCatchPattern":"try { GenerateReport(coverageSummaryFile); }\ncatch (Exception ex) { Error($\"Coverage reporting failed: {ex.Message}\"); throw; }","preventionTips":["Ensure the test task runs before the coverage task in the same invocation","Keep coverlet.collector referenced in all test projects","Align test output directory with artifactsForUnitTestsDir","Mind case-sensitive paths on Linux CI agents"],"tags":["code-coverage","coverlet","file-not-found","build-script"],"backgroundTag":"file-not-found","analyzedSha":"d1f22d930430410bfd0233f5e9e4f92980cf7df0","analyzedAt":"2026-09-12T13:50:06.067Z","contentChangedAt":"2026-09-12T13:50:06.067Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}