简体   繁体   中英

OpenCover for xUnit tests in .Net Core

I have 2 projects in my VS2017 .Net Core solution

  • Application (dll)
  • Application.Test (dll)

In the Application I have Service1.cs with class Service1 and in Application.Test I have Service1.Test.cs with xUnit unit tests for Service1 . In Application.Test.csproj file I have reference to Application like

<ItemGroup>
  <ProjectReference Include="..\Application.csproj" />
</ItemGroup>

Service1.Test compiles and runs well - I don't have any problems with it.

How can I call OpenCover (and ReportGenerator if possible) to analyze and create results of test coverage of Service1 by Service1.Test?

I tried to do like this:

dotnet.exe test "path to Application.Test" 

But I had results where Service1.Test covered itself - looks like OpenCover didn't "see" Application project and Service1 class at all.

You need to add the following items to the .csproj file.

<PropertyGroup>
  <DebugType>full</DebugType>
</PropertyGroup>

Required for both Application.csproj file and Application.Test.csproj file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM