SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.22k stars 751 forks source link

Cannot get code coverage reports for SpecFlow to generate #2732

Open jwenger100 opened 5 months ago

jwenger100 commented 5 months ago

SpecFlow Version

3.9.74"

Which test runner are you using?

xUnit

Test Runner Version Number

<PackageReference Include="xunit" Version="2.4.2" />

.NET Implementation

.NET 6.0

Project Format of the SpecFlow project

Sdk-style project format

.feature.cs files are generated using

SpecFlow.Tools.MsBuild.Generation NuGet package

Test Execution Method

Visual Studio Test Explorer

SpecFlow Section in app.config or content of specflow.json

N/A

Issue Description

I am trying to generate a code coverage report, I am interested to find out what % of lines are covered in each one of my projects within this solution. I have tried using the built in code coverage with Xunit, along with coverlet nuget package and I cannot get reports to generate with any data in them. They generate but are empty. Is there a recommended approach for accomplishing this?

Steps to Reproduce

  1. Run this command to execute the specflow tests, coverage should be generated but is not accurate.
  2. dotnet test --filter "FullyQualifiedName~IntTests" -p:CollectCoverage=true -p:CoverletOutputFormat=\"json,opencover\" -p:MergeWith="pwd/coverage.json" --logger "trx;LogFileName=TestResults.trx"

Link to Repro Project

No response