Skip to content

Update fork #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Update="Microsoft.Extensions.FileSystemGlobbing" Version="2.0.1" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Update="Microsoft.TestPlatform.ObjectModel" Version="16.1.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Update="Microsoft.TestPlatform.ObjectModel" Version="16.5.0" />
<PackageReference Update="Mono.Cecil" Version="0.11.1" />
<PackageReference Update="Moq" Version="4.10.1" />
<!-- Do not upgrade this version or we won't support old SDK -->
Expand Down
6 changes: 2 additions & 4 deletions Documentation/KnowIssues.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ This happen also if there are other "piece of code" during testing that slow dow
We found problem for instance with test that uses RabbitMQ.

*Solution:*
The only way to solve this issue is to use collectors integration https://github.com/tonerdo/coverlet#vstest-integration.
The only way to solve this issue is to use collectors integration https://github.com/tonerdo/coverlet#vstest-integration-preferred-due-to-know-issue.
With collector we're injected in test host throught a in-proc collector that talk with vstest platform so we can signal when we end our work.
Check requirements https://github.com/tonerdo/coverlet#requirements you need to run *.NET Core SDK v2.2.401 or newer*.

## 2) Upgrade `coverlet.collector` to version > 1.0.0

Expand All @@ -64,11 +63,10 @@ For instance
```xml
<ItemGroup>
...
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20191115-01" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
...
</ItemGroup>
```
***N.B. This document was updated after preview release of test platform package with fix, you should use official version of the package.***
2) You can pass custom *runsetting* file like this
```xml
<?xml version="1.0" encoding="utf-8" ?>
Expand Down
3 changes: 2 additions & 1 deletion Documentation/Troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,9 @@ Process Id: 29228 Name: dotnet

## Enable collector instrumentation debugging

You can live attach and debug collectors with `COVERLET_DATACOLLECTOR_OUTOFPROC_DEBUG` env variable
You can live attach and debug collectors with `COVERLET_DATACOLLECTOR_OUTOFPROC_DEBUG` and `COVERLET_DATACOLLECTOR_INPROC_DEBUG` env variable
```
set COVERLET_DATACOLLECTOR_OUTOFPROC_DEBUG=1
set COVERLET_DATACOLLECTOR_INPROC_DEBUG=1
```
You will be asket to attach a debugger through UI popup.
5 changes: 2 additions & 3 deletions Documentation/VSTestIntegration.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ A sample project file looks like:
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net46</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<!-- Temporary preview reference with essential vstest bug fix -->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20200116-01" />
<!-- Minimum version 16.5.0 -->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<!-- Update this reference when new version is released -->
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PrivateAssets>all</PrivateAssets>
Expand All @@ -21,7 +21,6 @@ A sample project file looks like:
...
</Project>
```
As you can see in sample above we're referencing a preview version of `Microsoft.NET.Test.Sdk`, this is temporary needed because there is a bug inside vstest platform during collectors loading([details](https://github.com/microsoft/vstest/issues/2205)). **At the moment there isn't a stable package released with fix so we need to use a preview**.

The reference to `coverlet.collector` package is included by default with xunit template test (`dotnet new xunit`), you only need to update the package for new versions like any other package reference.

Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,10 @@ After the above command is run, a `coverage.cobertura.xml` file containing the r
See [documentation](Documentation/VSTestIntegration.md) for advanced usage.

#### Requirements
* _You need to be running .NET Core SDK v2.2.300 or newer_
* _To run fully-featured collectors ([see #110](https://github.com/tonerdo/coverlet/issues/110)) you need to be running .NET Core SDK v2.2.401 or newer_
* _You need to reference version 16.1.0 and above of Microsoft.NET.Test.Sdk_
* _You need to be running .NET Core SDK v2.2.401 or newer_
* _You need to reference version 16.5.0 and above of Microsoft.NET.Test.Sdk_
```
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
```
#### Important temporary [know issue](Documentation/KnowIssues.md#2-upgrade-coverletcollector-to-version--100)

*Current* recommended test sdk package to reference
```
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0-preview-20200116-01" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
```

### MSBuild Integration
Expand Down Expand Up @@ -142,6 +135,16 @@ See the [documentation](Documentation/ConsumeNightlyBuild.md)

If you find a bug or have a feature request, please report them at this repository's issues section. See the [CONTRIBUTING GUIDE](CONTRIBUTING.md) for details on building and contributing to this project.

## Coverlet Team

Author and owner
* [Toni Solarin-Sodara](https://github.com/tonerdo)

Co-maintainers

* [Peter Liljenberg](https://github.com/petli)
* [Marco Rossignoli](https://github.com/MarcoRossignoli)

## Code of Conduct

This project enforces a code of conduct in line with the contributor covenant. See [CODE OF CONDUCT](CODE_OF_CONDUCT.md) for details.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using System.Reflection;

using coverlet.collector.Resources;
Expand All @@ -14,8 +15,20 @@ public class CoverletInProcDataCollector : InProcDataCollection
{
private TestPlatformEqtTrace _eqtTrace;

private void AttachDebugger()
{
if (int.TryParse(Environment.GetEnvironmentVariable("COVERLET_DATACOLLECTOR_INPROC_DEBUG"), out int result) && result == 1)
{
Debugger.Launch();
Debugger.Break();
}
}

public void Initialize(IDataCollectionSink dataCollectionSink)
{

AttachDebugger();

_eqtTrace = new TestPlatformEqtTrace();
_eqtTrace.Verbose("Initialize CoverletInProcDataCollector");
}
Expand Down
8 changes: 4 additions & 4 deletions test/coverlet.core.tests/Coverage/CoverageTests.AsyncAwait.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public void AsyncAwait_Issue_669_1()
((Task)instance.Test()).ConfigureAwait(false).GetAwaiter().GetResult();
return Task.CompletedTask;
},
persistPrepareResultToFile: pathSerialize, disableRestoreModules: true);
persistPrepareResultToFile: pathSerialize);

return 0;
}, path, invokeInProcess: true).Dispose();
}, path).Dispose();

TestInstrumentationHelper.GetCoverageResult(path)
.Document("Instrumentation.AsyncAwait.cs")
Expand Down Expand Up @@ -111,10 +111,10 @@ public void AsyncAwait_Issue_669_2()
((ValueTask<System.Net.Http.HttpResponseMessage>)instance.SendRequest()).ConfigureAwait(false).GetAwaiter().GetResult();
return Task.CompletedTask;
},
persistPrepareResultToFile: pathSerialize, disableRestoreModules: true);
persistPrepareResultToFile: pathSerialize);

return 0;
}, path, invokeInProcess: true).Dispose();
}, path).Dispose();

TestInstrumentationHelper.GetCoverageResult(path)
.Document("Instrumentation.AsyncAwait.cs")
Expand Down
14 changes: 11 additions & 3 deletions test/coverlet.integration.tests/Collectors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,19 @@ private protected override void AssertCollectorsInjection(ClonedTemplateProject
}
}

public class TestSDK_16_5_0 : Collectors
{
public TestSDK_16_5_0()
{
TestSDKVersion = "16.5.0";
}
}

public class TestSDK_Preview : Collectors
{
public TestSDK_Preview()
{
TestSDKVersion = "16.5.0-preview-20200110-02";
TestSDKVersion = "16.5.0-preview-20200203-01";
}
}

Expand All @@ -52,8 +60,8 @@ private ClonedTemplateProject PrepareTemplateProject()
private protected virtual void AssertCollectorsInjection(ClonedTemplateProject clonedTemplateProject)
{
// Check out/in process collectors injection
Assert.Contains("[coverlet]", File.ReadAllText(clonedTemplateProject.GetFiles("log.datacollector.*.txt").Single()));
Assert.Contains("[coverlet]", File.ReadAllText(clonedTemplateProject.GetFiles("log.host.*.txt").Single()));
Assert.Contains("[coverlet]Initializing CoverletCoverageDataCollector with configuration:", File.ReadAllText(clonedTemplateProject.GetFiles("log.datacollector.*.txt").Single()));
Assert.Contains("[coverlet]Initialize CoverletInProcDataCollector", File.ReadAllText(clonedTemplateProject.GetFiles("log.host.*.txt").Single()));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\coverlet.core\coverlet.core.csproj" />
<ProjectReference Include="$(RepoRoot)src\coverlet.core\coverlet.core.csproj" />
<ProjectReference Include="$(RepoRoot)test\coverlet.core.tests.samples.netstandard\coverlet.core.tests.samples.netstandard.csproj" />
</ItemGroup>

</Project>