Provides the integration with dotCover via the Visual Studio Test Platform. This package is an alternative way to run .NET tests under dotCover described in this post.
- .NET Core SDK 2.0+
- .NET 4.5+
- .NET Core 2.0+
- Windows
In brief, you can create a test project and run tests collecting code coverage statistics in 3 lines:
dotnet new mstest
dotnet add package TeamCity.dotCover
dotnet test
where mstest is the one of dotnet project templates.
The command dotnet add package TeamCity.dotCover
adds the TeamCity integration with dotCover by referencing the TeamCity dotCover integration package.
The final test project might look like the following:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net45;netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="TeamCity.dotCover" Version="2019.1.1" />
</ItemGroup>
</Project>
To run tests under dotCover use the .NET CLI plugin for or any other TeamCity runners which allow running a command equivalent to:
dotnet test
or
dotnet msbuild /t:VSTest
If you want to specify any argument you’ve used previously with dotCover, you can do this by simply adding the environment variable starting by TC_DC_
prefix to the variable name.
E.g., to specify an assembly filters, use the environment variable TC-DC_Filters
instead of --Filters
:
SET TC_DC_Filters=-:MyTests
To gather diagnostics information use the environment variable TC_DC_TRACE_FILE
and specify path to a trace file there. For instance:
SET TC_DC_TRACE_FILE=c:\temp\trace.txt
- Avoid specifying code coverage options in runners because the TeamCity dotCover integration package already runs your tests under dotCover.
- The gathering of code coverage statistics is turned off when tests are not running under TeamCity (for instance when tests are running locally).