Unable to see code coverage in Integration Test API Endpoint using TestHost and related type

Hello All,

Please Help I m stuck here.

I can not able to generate code coverage of my API endpoint test cases.

I tried with following commands. but code coverage showing 0.

dotnet restore “”

dotnet sonarscanner begin /k:"" /d:sonar.host.url="" /d:sonar.login=""

dotnet build “” -c Release -o /app/build

dotnet test “” /p:CollectCoverage=true /p:CoverletOutputFormat=opencover

dotnet sonarscanner end /d:sonar.login=

Hi Ankit,
Welcome to the community
SonarCloud does not automatically calculate test coverage. You need to use an external tool, like Jacoco to produce a coverage report, which SC then imports. For some help, have a look here:

and more generally, here:

Hi Peeter,
Thanks for reply
As I have written test case like directly call API endpoint(s). So its not cover whole line of my code.
Written Test case like this.

And Code-coverage output is

So Please help on this.

Hello @Peeter_Piegaze ,

Please help on this.

I have found one link on R & D. visual studio 2013 - Sonarqube C# unable to display Integration test/coverage results - Stack Overflow says that Integration test not supported in sonar.

Is Integration test support on sonar to generate code coverage ?

If Yes then How… I was stuck on last one week @All Please Help.

Hi Ankit,

As I mentioned, you need to set up the tool to produce code coverage yourself, then configure SonarCloud to read the report. Since it looks like you are using C# you might want to have a look at this post:

HI @Peeter_Piegaze,

Yes, I follow that and generate code coverage of Unit Test in C#. But cant generate for Integration Test report. In my solution we wrote integration test cases for WEB Apis. So I need to generate that reports.