Merge pull request #9681 from dotnet/merges/release/2.1.4xx-to-release/2.1.401
Merge release/2.1.4xx to release/2.1.401
This commit is contained in:
commit
cdffcec1f1
10 changed files with 166 additions and 8 deletions
|
@ -7,8 +7,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.0.6-preview" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.1.5-preview" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -10,8 +10,8 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.0.6-preview" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.1.5-preview" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestVersion)" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestVersion)" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -8,8 +8,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
|
||||
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
|
||||
<PackageReference Include="xunit" Version="2.2.0-beta4-build3444" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta4-build1194" />
|
||||
<PackageReference Include="xunit" Version="$(XUnitVersion)" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="$(XUnitVersion)" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -58,6 +58,8 @@
|
|||
<MicrosoftTestPlatformBuildPackageVersion>$(MicrosoftNETTestSdkPackageVersion)</MicrosoftTestPlatformBuildPackageVersion>
|
||||
<XliffTasksPackageVersion>0.2.0-beta-000042</XliffTasksPackageVersion>
|
||||
<MicroBuildCorePackageVersion>0.2.0</MicroBuildCorePackageVersion>
|
||||
<MSTestVersion>1.3.2</MSTestVersion>
|
||||
<XUnitVersion>2.3.1</XUnitVersion>
|
||||
<NUnit3TemplatesVersion>1.5.1</NUnit3TemplatesVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
<NugetConfigCLIFeeds>
|
||||
<![CDATA[
|
||||
<add key="myget-vstest" value="https://dotnet.myget.org/F/vstest/api/v3/index.json" />
|
||||
<add key="BlobFeed" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
|
||||
<add key="aspnetcore-dev" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" />
|
||||
<add key="templating" value="https://dotnet.myget.org/F/templating/api/v3/index.json" />
|
||||
|
|
25
test/dotnet-test.Tests/CollectCodeCoverage.runsettings
Normal file
25
test/dotnet-test.Tests/CollectCodeCoverage.runsettings
Normal file
|
@ -0,0 +1,25 @@
|
|||
<RunSettings>
|
||||
<DataCollectionRunSettings>
|
||||
<DataCollectors>
|
||||
<DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0">
|
||||
<Configuration>
|
||||
<CodeCoverage>
|
||||
<!-- Match assembly file paths: -->
|
||||
<ModulePaths>
|
||||
<Exclude>
|
||||
<ModulePath>.*Test.dll</ModulePath>
|
||||
</Exclude>
|
||||
</ModulePaths>
|
||||
|
||||
<!-- We recommend you do not change the following values: -->
|
||||
<UseVerifiableInstrumentation>True</UseVerifiableInstrumentation>
|
||||
<AllowLowIntegrityProcesses>True</AllowLowIntegrityProcesses>
|
||||
<CollectFromChildProcesses>True</CollectFromChildProcesses>
|
||||
<CollectAspDotNet>False</CollectAspDotNet>
|
||||
|
||||
</CodeCoverage>
|
||||
</Configuration>
|
||||
</DataCollector>
|
||||
</DataCollectors>
|
||||
</DataCollectionRunSettings>
|
||||
</RunSettings>
|
|
@ -84,6 +84,36 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
result.ExitCode.Should().Be(1);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void ItCreatesTwoCoverageFilesForMultiTargetedProject()
|
||||
{
|
||||
// Copy XunitMulti project in output directory of project dotnet-test.Tests
|
||||
string testAppName = "XunitMulti";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance("3")
|
||||
.WithSourceFiles();
|
||||
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
|
||||
string resultsDirectory = Path.Combine(testProjectDirectory, "RD");
|
||||
|
||||
// Delete resultsDirectory if it exist
|
||||
if (Directory.Exists(resultsDirectory))
|
||||
{
|
||||
Directory.Delete(resultsDirectory, true);
|
||||
}
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput($"{TestBase.ConsoleLoggerOutputNormal} --collect \"Code Coverage\" --results-directory {resultsDirectory}");
|
||||
|
||||
// Verify
|
||||
DirectoryInfo d = new DirectoryInfo(resultsDirectory);
|
||||
FileInfo[] coverageFileInfos = d.GetFiles("*.coverage", SearchOption.AllDirectories);
|
||||
Assert.Equal(2, coverageFileInfos.Length);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItCanTestAMultiTFMProjectWithImplicitRestore()
|
||||
{
|
||||
|
|
|
@ -9,6 +9,7 @@ using Microsoft.DotNet.Cli.Utils;
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Xml;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Test.Tests
|
||||
{
|
||||
|
@ -311,6 +312,100 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
result.ExitCode.Should().Be(1);
|
||||
}
|
||||
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void ItCreatesCoverageFileWhenCodeCoverageEnabledByRunsettings()
|
||||
{
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("11");
|
||||
|
||||
string resultsDirectory = Path.Combine(testProjectDirectory, "RD");
|
||||
|
||||
// Delete resultsDirectory if it exist
|
||||
if (Directory.Exists(resultsDirectory))
|
||||
{
|
||||
Directory.Delete(resultsDirectory, true);
|
||||
}
|
||||
|
||||
var settingsPath =Path.Combine(AppContext.BaseDirectory, "CollectCodeCoverage.runsettings");
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput(
|
||||
"--settings " + settingsPath
|
||||
+ " --results-directory " + resultsDirectory);
|
||||
|
||||
// Verify test results
|
||||
if (!DotnetUnderTest.IsLocalized())
|
||||
{
|
||||
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
|
||||
}
|
||||
|
||||
// Verify coverage file.
|
||||
DirectoryInfo d = new DirectoryInfo(resultsDirectory);
|
||||
FileInfo[] coverageFileInfos = d.GetFiles("*.coverage", SearchOption.AllDirectories);
|
||||
Assert.Equal(1, coverageFileInfos.Length);
|
||||
|
||||
result.ExitCode.Should().Be(1);
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void ItCreatesCoverageFileInResultsDirectory()
|
||||
{
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("12");
|
||||
|
||||
string resultsDirectory = Path.Combine(testProjectDirectory, "RD");
|
||||
|
||||
// Delete resultsDirectory if it exist
|
||||
if (Directory.Exists(resultsDirectory))
|
||||
{
|
||||
Directory.Delete(resultsDirectory, true);
|
||||
}
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput(
|
||||
"--collect \"Code Coverage\" "
|
||||
+ "--results-directory " + resultsDirectory);
|
||||
|
||||
// Verify test results
|
||||
if (!DotnetUnderTest.IsLocalized())
|
||||
{
|
||||
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
|
||||
}
|
||||
|
||||
// Verify coverage file.
|
||||
DirectoryInfo d = new DirectoryInfo(resultsDirectory);
|
||||
FileInfo[] coverageFileInfos = d.GetFiles("*.coverage", SearchOption.AllDirectories);
|
||||
Assert.Equal(1, coverageFileInfos.Length);
|
||||
|
||||
result.ExitCode.Should().Be(1);
|
||||
}
|
||||
|
||||
[UnixOnlyFact]
|
||||
public void ItShouldShowWarningMessageOnCollectCodeCoverage()
|
||||
{
|
||||
var testProjectDirectory = this.CopyAndRestoreVSTestDotNetCoreTestApp("13");
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput(
|
||||
"--collect \"Code Coverage\" "
|
||||
+ "--filter VSTestPassTest");
|
||||
|
||||
// Verify test results
|
||||
if (!DotnetUnderTest.IsLocalized())
|
||||
{
|
||||
result.StdOut.Should().Contain("No code coverage data available. Code coverage is currently supported only on Windows.");
|
||||
result.StdOut.Should().Contain("Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.");
|
||||
result.StdOut.Should().Contain("Test Run Successful.");
|
||||
}
|
||||
|
||||
result.ExitCode.Should().Be(0);
|
||||
}
|
||||
|
||||
private string CopyAndRestoreVSTestDotNetCoreTestApp([CallerMemberName] string callingMethod = "")
|
||||
{
|
||||
// Copy VSTestCore project in output directory of project dotnet-vstest.Tests
|
||||
|
|
|
@ -16,4 +16,9 @@
|
|||
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.2.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Update="CollectCodeCoverage.runsettings">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in a new issue