@@ -1,30 +1,22 @@
|
||||
# Coverlet Integration with VSTest
|
||||
|
||||
## Motivation
|
||||
|
||||
The cross platform solution for Code Coverage generation for .NET Core projects (in a consistent manner).
|
||||
The asks for Code Coverage support for .NET Core on Linux is the most commented issue on vstest repo:
|
||||
https://github.com/Microsoft/vstest/issues/981#issuecomment-320311552
|
||||
|
||||
## Summary
|
||||
|
||||
What would integrating Coverlet with Microsoft Test Platform mean:
|
||||
|
||||
1. Coverlet based coverage solution is available as a data collector that does the instrumentation of the necessary modules before test execution and appropriate restore after.
|
||||
2. Authoring - When new test projects are created (dotnet mstest), references to the data collector package are added by default. This reduces adoption friction for customers.
|
||||
3. Test execution - Today Coverlet is invoked as a msbuild target and as such only works with dotnet test (and requires a csproj). With the data collector becoming available, coverage can also be collected when tests are run on built binaries (dotnet vstest)
|
||||
|
||||
## Proposed Solution
|
||||
|
||||
### Scenarios to support
|
||||
|
||||
The following table summarizes the support that needs to be added for a seamless code coverage collection for .NET Core on both Linux and Windows platforms:
|
||||
|
||||
| Entry point | How will code coverage be enabled? | Syntax |
|
||||
|-------------|------------------------------------|----------------------------------------------------------------------|
|
||||
|dotnet test CLI | Through a switch to condition data collection | `dotnet test --collect:"XPlat Code Coverage"` |
|
||||
|dotnet vstest CLI | Through a switch to condition data collection | `dotnet vstest --collect:"XPlat Code Coverage"` |
|
||||
|
||||
NB. If you're using `dotnet vstest` you MUST `publish` your test project before i.e.
|
||||
```bash
|
||||
C:\project
|
||||
dotnet publish
|
||||
...
|
||||
vstest -> C:\project\bin\Debug\netcoreapp3.0\testdll.dll
|
||||
vstest -> C:\project\bin\Debug\netcoreapp3.0\publish\
|
||||
...
|
||||
dotnet vstest C:\project\bin\Debug\netcoreapp3.0\publish\testdll.dll --collect:"XPlat Code Coverage"
|
||||
```
|
||||
|
||||
### Coverlet Options Supported with VSTest
|
||||
|
||||
#### Default
|
||||
@@ -75,11 +67,6 @@ This runsettings file can easily be provided using command line option as given
|
||||
|
||||
2. `dotnet vstest --settings coverletArgs.runsettings`
|
||||
|
||||
|
||||
#### Scope of Enhancement
|
||||
|
||||
Currently, advanced options are supported via runsettings. Providing support through additional command line arguments in vstest can be taken up separately.
|
||||
|
||||
## Implementation Details
|
||||
|
||||
The proposed solution is implemented with the help of [datacollectors](https://github.com/Microsoft/vstest-docs/blob/master/docs/extensions/datacollector.md).
|
||||
|
||||
Reference in New Issue
Block a user