e1916cc4dc
* dotnet/release/15.5: (21 commits) Manually merging some changes that git merged wrong and deleted from the 15.5 branch. Separating the 'legacy' URL construction from the 'current' URL construction methods and logic. Use temporary path for fake deps.json in test Use same build number for roslyn and F# satellites Updating Roslyn satellites and SDK versions Insert NuGet Build 4.5.0-preview2-4529 into cli Update NuGet to 4529 (signed) MSBuild 15.5.154 MSBuild 15.5.153 removed commented out config I'd meant to remove added a way to specify the asp.net template versions Porting 'dotnet-install.sh' from CLI:master to CLI:release/2.0.0 'NuGet.master.config' does not appear to be used. Fixed tests Update branch info to release/15.5 Updating the websdk version to 2.0.0-rel-20171010-665 Insert NuGet Build 4.5.0-preview1-4526 into cli Update DependencyVersions.props Updated version of TestPlatform to 15.5.0-preview-20170923-02 MSBuild 15.4.8 ...
104 lines
4.2 KiB
C#
104 lines
4.2 KiB
C#
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
using FluentAssertions;
|
|
using Microsoft.DotNet.TestFramework;
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
using System.IO;
|
|
using System;
|
|
using Xunit;
|
|
|
|
namespace Microsoft.DotNet.Cli.Test.Tests
|
|
{
|
|
public class GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
|
|
{
|
|
[WindowsOnlyFact]
|
|
public void MStestMultiTFM()
|
|
{
|
|
var testProjectDirectory = TestAssets.Get("VSTestMulti")
|
|
.CreateInstance("1")
|
|
.WithSourceFiles()
|
|
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
|
|
.Root;
|
|
|
|
var runtime = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
|
|
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.WithRuntime(runtime)
|
|
.Execute()
|
|
.Should().Pass();
|
|
|
|
var result = new DotnetTestCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.WithRuntime(runtime)
|
|
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
|
|
|
|
if (!DotnetUnderTest.IsLocalized())
|
|
{
|
|
result.StdOut
|
|
.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.", "because .NET 4.6 tests will pass")
|
|
.And.Contain("Passed VSTestPassTestDesktop", "because .NET 4.6 tests will pass")
|
|
.And.Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.", "because netcoreapp2.0 tests will fail")
|
|
.And.Contain("Failed VSTestFailTestNetCoreApp", "because netcoreapp2.0 tests will fail");
|
|
}
|
|
result.ExitCode.Should().Be(1);
|
|
}
|
|
|
|
[WindowsOnlyFact]
|
|
public void XunitMultiTFM()
|
|
{
|
|
// Copy XunitMulti project in output directory of project dotnet-test.Tests
|
|
string testAppName = "XunitMulti";
|
|
var testInstance = TestAssets.Get(testAppName)
|
|
.CreateInstance("2")
|
|
.WithSourceFiles();
|
|
|
|
var testProjectDirectory = testInstance.Root.FullName;
|
|
|
|
// Restore project XunitMulti
|
|
new RestoreCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.Execute()
|
|
.Should()
|
|
.Pass();
|
|
|
|
// Call test
|
|
CommandResult result = new DotnetTestCommand()
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
.ExecuteWithCapturedOutput(TestBase.ConsoleLoggerOutputNormal);
|
|
|
|
// Verify
|
|
if (!DotnetUnderTest.IsLocalized())
|
|
{
|
|
// for target framework net46
|
|
result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.");
|
|
result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTestDesktop");
|
|
|
|
// for target framework netcoreapp1.0
|
|
result.StdOut.Should().Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.");
|
|
result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTestNetCoreApp");
|
|
}
|
|
|
|
result.ExitCode.Should().Be(1);
|
|
}
|
|
|
|
[Fact]
|
|
public void ItCanTestAMultiTFMProjectWithImplicitRestore()
|
|
{
|
|
var testInstance = TestAssets.Get(
|
|
TestAssetKinds.DesktopTestProjects,
|
|
"MultiTFMXunitProject")
|
|
.CreateInstance()
|
|
.WithSourceFiles();
|
|
|
|
string projectDirectory = Path.Combine(testInstance.Root.FullName, "XUnitProject");
|
|
|
|
new DotnetTestCommand()
|
|
.WithWorkingDirectory(projectDirectory)
|
|
.ExecuteWithCapturedOutput($"{TestBase.ConsoleLoggerOutputNormal} --framework netcoreapp2.1")
|
|
.Should().Pass();
|
|
}
|
|
}
|
|
}
|