-1

I'm using coverlet and .Net Core to develop an API, I started to make unit tests (the only tool I've found for .Net Core was coverlet).

I got the coverage, but I only can get files like json, xml etc.

I would need to see an HTML or something more visual to be able to handle the tests fastly.

Here is my current output on terminal:

+---------------------------+--------+--------+--------+
| Module                    | Line   | Branch | Method |
+---------------------------+--------+--------+--------+
| rede-merchants-cancel-api | 12,5%  | 0%     | 16,7%  |
+---------------------------+--------+--------+--------+

And a part of the output with json:

"Program.cs": {
  "Program": {
    "System.Void rede_merchants_cancel_api.Program::Main(System.String[])": {
      "Lines": {
        "9": 0,
        "10": 0,
        "11": 0
      },
      "Branches": []
    },
    "Microsoft.AspNetCore.Hosting.IWebHost rede_merchants_cancel_api.Program::BuildWebHost(System.String[])": {
      "Lines": {
        "14": 0,
        "15": 0,
        "16": 0
      },
      "Branches": []
    }
  }
}

There is some tool to make that?

  • Why the downvote? That's ok about that, but I'd like to know what to improve. – Felipe Augusto Aug 17 '18 at 20:00
  • 1
    Thanks, reopened as it's no longer off-topic. Not my area of proficience though, so I cannot tell what might be missing (the down-voter might have an idea). Good luck then! – Izzy Aug 18 '18 at 17:27
0

I've found an answer, what I tried first was using the docker-dotnet-sonarscanner, but I couldn't setting that very well, then I adopted another approach:

  1. Install coverlet, which gives me the code coverage for .Net Core in many formats: json (default), lcov, opencover and cobertura.
  2. Install a plugin for VSCode where I could see the code coverage in a nice way, and its name is coverage-gutters.
  3. Use the command available on the coverlet docs to output the code coverage with the lcov format, to be able to use with the plugin of code coverage.
  4. Extra - Use a plugin to run the tests on VSCode instead of CLI (I didn't tried that), with .Net Test Explorer it's possible but I think it would be necessary to change the command to be able to output what you need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.