|
1 | 1 | # Coverlet Integration with VSTest
|
2 | 2 |
|
3 |
| -## Motivation |
4 |
| - |
5 |
| -The cross platform solution for Code Coverage generation for .NET Core projects (in a consistent manner). |
6 |
| -The asks for Code Coverage support for .NET Core on Linux is the most commented issue on vstest repo: |
7 |
| -https://github.com/Microsoft/vstest/issues/981#issuecomment-320311552 |
8 |
| - |
9 |
| -## Summary |
10 |
| - |
11 |
| -What would integrating Coverlet with Microsoft Test Platform mean: |
12 |
| - |
13 |
| -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. |
14 |
| -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. |
15 |
| -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) |
16 |
| - |
17 |
| -## Proposed Solution |
18 |
| - |
19 |
| -### Scenarios to support |
20 |
| - |
21 |
| -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: |
22 | 3 |
|
23 | 4 | | Entry point | How will code coverage be enabled? | Syntax |
|
24 | 5 | |-------------|------------------------------------|----------------------------------------------------------------------|
|
25 | 6 | |dotnet test CLI | Through a switch to condition data collection | `dotnet test --collect:"XPlat Code Coverage"` |
|
26 | 7 | |dotnet vstest CLI | Through a switch to condition data collection | `dotnet vstest --collect:"XPlat Code Coverage"` |
|
27 | 8 |
|
| 9 | +NB. If you're using `dotnet vstest` you MUST `publish` your test project before i.e. |
| 10 | +```bash |
| 11 | +C:\project |
| 12 | +dotnet publish |
| 13 | +... |
| 14 | + vstest -> C:\project\bin\Debug\netcoreapp3.0\testdll.dll |
| 15 | + vstest -> C:\project\bin\Debug\netcoreapp3.0\publish\ |
| 16 | +... |
| 17 | +dotnet vstest C:\project\bin\Debug\netcoreapp3.0\publish\testdll.dll --collect:"XPlat Code Coverage" |
| 18 | +``` |
| 19 | + |
28 | 20 | ### Coverlet Options Supported with VSTest
|
29 | 21 |
|
30 | 22 | #### Default
|
@@ -75,11 +67,6 @@ This runsettings file can easily be provided using command line option as given
|
75 | 67 |
|
76 | 68 | 2. `dotnet vstest --settings coverletArgs.runsettings`
|
77 | 69 |
|
78 |
| - |
79 |
| -#### Scope of Enhancement |
80 |
| - |
81 |
| -Currently, advanced options are supported via runsettings. Providing support through additional command line arguments in vstest can be taken up separately. |
82 |
| - |
83 | 70 | ## Implementation Details
|
84 | 71 |
|
85 | 72 | The proposed solution is implemented with the help of [datacollectors](https://github.com/Microsoft/vstest-docs/blob/master/docs/extensions/datacollector.md).
|
|
0 commit comments