test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

.NET, Cobertura, Code Climate generates invalid results

Open zedseven opened this issue 3 years ago • 2 comments

Hi, I recently decided to set up Code Climate for my repository, but I've been having a lot of issues.

I generate coverage reports with Coverlet, using the following command:

dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura RomanizationTests/RomanizationTests.csproj

This creates RomanizationTests/coverage.cobertura.xml. As far as I can tell this file is without issue, and correct. I then process it with the following:

./cc-test-reporter format-coverage --input-type cobertura --output RomanizationTests/codeclimate.json RomanizationTests/coverage.cobertura.xml
./cc-test-reporter upload-coverage --input RomanizationTests/codeclimate.json

The file is successfully uploaded to Code Climate, but I get the following error: image With the full error:

{
  "message": "Invalid path part \"/\"",
  "file_document": "{
    \"_id\"=>BSON::ObjectId('601f0378f8aa324544001911'),
    \"type\"=>\"test_file_reports\",
    \"blob_id\"=>\"ef8306fb90e8f744279ee7f4df8eece02ff9d4d5\",
    \"coverage\"=>\"[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,0,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,3,3,null,null,null,null,3,3,67749,79047,3,null,null,null,null,null,null,null,null,null,null,null,0,0,null,null,null,null,null,null,null,null,null,null,16,56,null,null,null,null,null,null,null,null,null,null,null,2,2,2,2,null,null,null,null,null,null,null,null,null,null,null,19,19,53,53,19,53,136,53,119,19,53,53,19,null,null,null,null,null,null,null,null,null,null,19]\",
    \"covered_percent\"=>90,
    \"covered_strength\"=>4919.266666666666,
    \"line_counts\"=>{
      \"missed\"=>3,
      \"covered\"=>27,
      \"total\"=>30
    },
    \"path\"=>\"Romanization//Languages/Japanese/KanjiReadings.cs\",
    \"test_report_id\"=>BSON::ObjectId('601f0378c4082a440f001a32')
  }"
}

The issue is clearly with the double / in the path, but it makes no sense. Romanization/Languages/Japanese/KanjiReadings.cs is about halfway through the file list, and there are way more files than just it in the repo.

Am I missing something obvious, or is this a known issue?

For reference

zedseven avatar Feb 06 '21 22:02 zedseven

I just tried it using the lcov format instead of cobertura, and the test seems to be valid. This seems to be an issue with the Cobertura format in some regard.

zedseven avatar Feb 07 '21 19:02 zedseven

@efueger Is this on our radar already?

filipesperandio avatar Apr 30 '21 00:04 filipesperandio