question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LCOV report type empty when using C# code coverage JSON file

See original GitHub issue

Describe the bug I am currently having an issue where the produced lcov.info file is empty. The only content it has in it is a single line of text at the top that is TN.

I have a NET 5.0 library that I am running tests for using GitHub actions. Once the tests produce the coverage result in lcov format, I am pointing the reportgenerator to the produced coverage.json file created with the tests from the previous step.

I am trying to use the coverallsapp v1.1.2 GitHub action to pick up the lcov.info file and that is when coveralls reports back to me that it cannot parse the string. Upon investigation, revealed that the lcov.info file was empty.

coveralls error: image

This is the unit testing section of my YAML

  Run_Unit_Tests:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v2
      
      - name: Setup .NET 5.0.x
        uses: actions/setup-dotnet@v1
        with:
          dotnet-version: 5.0.x
      
      - name: Restore Dependencies
        run: dotnet restore
      
      - name: Execute Unit Tests
        run: dotnet test "${{ github.workspace }}\\Testing\\CASLTests\\CASLTests.csproj" -c Debug-WIN /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOuputFormat=lcov
      
      - name: ReportGenerator
        uses: danielpalme/ReportGenerator-GitHub-Action@4.8.11
        with:
          reports: "**/TestResults/coverage.json"
          targetdir: "${{ github.workspace }}\\Testing\\CASLTests\\TestResults"
          reporttypes: lcov

      - name: Publish Code Coverage Results
        uses: coverallsapp/github-action@v1.1.2
        with:
          github-token: ${{ secrets.COVERALLS_TOKEN }}
          path-to-lcov: "${{ github.workspace }}\\Testing\\CASLTests\\TestResults\\lcov.info"

To Reproduce

  1. Console output of ReportGenerator image

  2. Here is a zip with 2 files in it. The coverage.json files is the file produced by the dotnet cli. Of course the lcov.info file is produced by the report generator. GeneratedCoverageFiles.zip

To reproduce this, I simply ran the same commands that is being performed in the YAML file.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
CalvinWilkinsoncommented, Jul 2, 2021

Quick Update

So I was able to get the Cobertura.xml to not be empty by using a different command. I will admit that I do not understand why one works over the other and the reason or true difference between the 2, but it is working.

Old Command: dotnet test "MyProject.csproj" -c Debug /p:CollectCoverage=true /p:CoverletOutput=TestResults/ /p:CoverletOuputFormat=cobertura

New Command: dotnet test "MyProject.csproj" -c Debug --collect:"XPlat Code Coverage"

This means that I did not need to use ReportGenerator at all. The new command simply generated the coverage.cobertura.xml file for me, which I had picked up by codecov.

I am good to go. Thanks for your help!! It led me in the right direction to solve the problem.

I just wanted to update this issue to hopefully help other people out.

0reactions
danielpalmecommented, Jul 2, 2021

Great that you found a solution.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Empty code coverage report is generated when test files ...
an empty code coverage report is generated when the test files exist in an external respository that has its own WORKSPACE file. following ......
Read more >
Lcov-parse usage is not clear
Again data here is the lcov file parsed into a JSON object. To run it: 1) First install the lcov-parse tool with npm:...
Read more >
Configuring Test Coverage
Configure your CI to temporarily store the reports from each separate test suite. We recommend syncing and fetching files from S3 as one...
Read more >
Command line usage — Coverage.py 7.2.4 documentation
lcov – Produce an LCOV report with coverage results. annotate – Annotate source files ... --data-file=OUTFILE Write the recorded coverage data to this...
Read more >
llvm-cov - emit coverage information
The llvm-cov gcov tool reads code coverage data files and displays the coverage information for a specified source file. It is compatible with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found