-
-
Notifications
You must be signed in to change notification settings - Fork 46
-
(I thought I already posted this question, but now can't find it. Must have dreamt it).
This is for Terminal.Gui...
We have 275 unit tests. They run fine.
Here's the UnitTests.csproj
:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0</TargetFramework> <IsPackable>false</IsPackable> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> <DefineConstants>TRACE</DefineConstants> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <DefineConstants>TRACE;DEBUG_IDISPOSABLE</DefineConstants> </PropertyGroup> <ItemGroup> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" /> <PackageReference Include="System.Collections" Version="4.3.0" /> <PackageReference Include="xunit" Version="2.4.1" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.4.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> <PackageReference Include="coverlet.collector" Version="3.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> </ItemGroup> <ItemGroup> <ProjectReference Include="..\Terminal.Gui\Terminal.Gui.csproj" /> <ProjectReference Include="..\UICatalog\UICatalog.csproj" /> </ItemGroup> </Project>
I've installed the Fine Code Coverage extension. But when I build, I don't get any results:
image
This is even after I ran dotnet test /p:CollectCoverage=true
manually:
> dotnet test /p:CollectCoverage=true
Determining projects to restore...
Restored C:\Users\charlie\s\gui.cs\Example\Example.csproj (in 191 ms).
Restored C:\Users\charlie\s\gui.cs\UICatalog\UICatalog.csproj (in 191 ms).
Restored C:\Users\charlie\s\gui.cs\Terminal.Gui\Terminal.Gui.csproj (in 191 ms).
Restored C:\Users\charlie\s\gui.cs\UnitTests\UnitTests.csproj (in 272 ms).
1 of 5 projects are up-to-date for restore.
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\net472\Terminal.Gui.dll
Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\netstandard2.0\Terminal.Gui.dll
Terminal.Gui -> C:\Users\charlie\s\gui.cs\Terminal.Gui\bin\Debug\net5.0\Terminal.Gui.dll
You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
UICatalog -> C:\Users\charlie\s\gui.cs\UICatalog\bin\Debug\net5.0\UICatalog.dll
UnitTests -> C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\UnitTests.dll
Test run for C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\UnitTests.dll (.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 16.9.0
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 275, Skipped: 0, Total: 275, Duration: 989 ms - UnitTests.dll (net5.0)
What am I missing?
Beta Was this translation helpful? Give feedback.
All reactions
<UseDataCollector/>
did the trick!
Thank you!
Replies: 3 comments 9 replies
-
But when I build, I don't get any results:
This is even after I ran dotnet test /p:CollectCoverage=true manually:
This is because
From fine code coverage readme
Fine Code Coverage works by reacting to the visual studio test explorer, providing coverage from each test project containing tests that you have selected to run
Beta Was this translation helpful? Give feedback.
All reactions
-
What version of FCC are you running ?
Beta Was this translation helpful? Give feedback.
All reactions
-
What version of FCC are you running ?
Beta Was this translation helpful? Give feedback.
All reactions
-
Then you should have the FCC output window pane
Beta Was this translation helpful? Give feedback.
All reactions
-
I restarted VS and tried again. The FCC output is now there.
However, it's still not actually working:
Fine Code Coverage : Initializing
Fine Code Coverage : Initialized
Fine Code Coverage : ================================== START ==================================
Fine Code Coverage : Run Coverage Tool (UnitTests)
Fine Code Coverage : Coverlet Run (UnitTests) Arguments
"C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\build-output\UnitTests.dll"
--format "cobertura"
--exclude-by-file "**/Migrations/*"
--exclude-by-attribute "GeneratedCode"
--include-test-assembly
--target "dotnet"
--threshold-type line
--threshold-stat total
--threshold 0
--output "C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\UnitTests.coverage.xml"
--targetargs "test ""C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\build-output\UnitTests.dll"" --nologo --blame --results-directory ""C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output"" --diag ""C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output/diagnostics.log"" "
Fine Code Coverage : Coverlet Run (UnitTests)
Starting test execution, please wait...
Logging Vstest Diagnostics in file: C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\diagnostics.log
A total of 1 test files matched the specified pattern.
Passed! - Failed: 0, Passed: 275, Skipped: 0, Total: 275, Duration: 1 s - UnitTests.dll (net5.0)
Calculating coverage result...
Generating report 'C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\UnitTests.coverage.xml'
+--------------+------+--------+--------+
| Module | Line | Branch | Method |
+--------------+------+--------+--------+
| Terminal.Gui | 0% | 0% | 0% |
+--------------+------+--------+--------+
| UICatalog | 0% | 0% | 0% |
+--------------+------+--------+--------+
| UnitTests | 0% | 0% | 0% |
+--------------+------+--------+--------+
+---------+------+--------+--------+
| | Line | Branch | Method |
+---------+------+--------+--------+
| Total | 0% | 0% | 0% |
+---------+------+--------+--------+
| Average | 0% | 0% | 0% |
+---------+------+--------+--------+
Fine Code Coverage : ReportGenerator Run Arguments [reporttype:Cobertura]
"-targetdir:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output"
"-reports:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\UnitTests.coverage.xml"
"-reporttypes:Cobertura"
Fine Code Coverage : ReportGenerator Run [reporttype:Cobertura]
2021年04月20日T11:51:11: Arguments
2021年04月20日T11:51:11: -targetdir:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output
2021年04月20日T11:51:11: -reports:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\UnitTests.coverage.xml
2021年04月20日T11:51:11: -reporttypes:Cobertura
2021年04月20日T11:51:12: Writing report file 'C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\Cobertura.xml'
2021年04月20日T11:51:12: Report generation took 0.6 seconds
Fine Code Coverage : ReportGenerator Run Arguments [reporttype:HtmlInline_AzurePipelines]
"-targetdir:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output"
"-reports:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\Cobertura.xml"
"-plugins:c:\users\charlie\appdata\local\microsoft\visualstudio16円.0_91ecdc36\extensions\sm0zu51i.koc\ReportGeneratorPlugins.dll"
"-reporttypes:FccDark"
Fine Code Coverage : ReportGenerator Run [reporttype:HtmlInline_AzurePipelines]
2021年04月20日T11:51:12: Arguments
2021年04月20日T11:51:12: -targetdir:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output
2021年04月20日T11:51:12: -reports:C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\Cobertura.xml
2021年04月20日T11:51:12: -plugins:c:\users\charlie\appdata\local\microsoft\visualstudio16円.0_91ecdc36\extensions\sm0zu51i.koc\ReportGeneratorPlugins.dll
2021年04月20日T11:51:12: -reporttypes:FccDark
2021年04月20日T11:51:13: Writing report file 'C:\Users\charlie\s\gui.cs\UnitTests\bin\Debug\net5.0\fine-code-coverage\coverage-tool-output\index.html'
2021年04月20日T11:51:13: Report generation took 0.6 seconds
Fine Code Coverage : ================================== DONE ==================================
Beta Was this translation helpful? Give feedback.
All reactions
-
I had the same results until
From the readme
<PropertyGroup>
<UseDataCollector/>
</PropertyGroup>
Coverlet has different "drivers". Fine Code Coverage has in the past only used the coverlet console driver. This has some issues associated with it. It is now possible to switch to the Data Collector driver. This is the better driver but cannot be used for all projects. For now this is opt in. In the future Fine Code Coverage will determine the appropriate driver. Please consult coverlet docs for version support. ** Note that it is unnecessary to add the nuget coverlet.collector package as FCC internally supplies coverlet.collector 3.0.3** Fine Code Coverage will use the Data Collector driver under two circumstances :
You are testing with runsettings that contains the coverlet collector ( and not disabled)
You set the UseDataCollector project property
After I set UseDataCollector
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
I have the same problem where do I have to add the
<PropertyGroup>
<UseDataCollector/>
</PropertyGroup>
in the test project or the project I want to test?
Beta Was this translation helpful? Give feedback.
All reactions
-
In the test project
Beta Was this translation helpful? Give feedback.