2016-10-28 14:45:38 +00:00
|
|
|
|
// 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;
|
2016-11-01 20:15:44 +00:00
|
|
|
|
using System;
|
2016-10-28 14:45:38 +00:00
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli.Test.Tests
|
|
|
|
|
{
|
|
|
|
|
public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
|
|
|
|
|
{
|
2016-11-04 05:12:33 +00:00
|
|
|
|
[WindowsOnlyFact(Skip="https://github.com/dotnet/cli/issues/4616")]
|
2016-11-02 18:08:20 +00:00
|
|
|
|
public void MStestMultiTFM()
|
2016-10-28 14:45:38 +00:00
|
|
|
|
{
|
2016-11-04 05:12:33 +00:00
|
|
|
|
var testProjectDirectory = TestAssets.Get("VSTestDesktopAndNetCore")
|
|
|
|
|
.CreateInstance()
|
|
|
|
|
.WithSourceFiles()
|
|
|
|
|
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
|
|
|
|
|
.Root;
|
|
|
|
|
|
|
|
|
|
var runtime = DotnetLegacyRuntimeIdentifiers.InferLegacyRestoreRuntimeIdentifier();
|
2016-10-28 14:45:38 +00:00
|
|
|
|
|
|
|
|
|
new RestoreCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-11-04 05:12:33 +00:00
|
|
|
|
.WithRuntime(runtime)
|
2016-10-28 14:45:38 +00:00
|
|
|
|
.Execute()
|
2016-11-04 05:12:33 +00:00
|
|
|
|
.Should().Pass();
|
2016-10-28 14:45:38 +00:00
|
|
|
|
|
2016-11-04 05:12:33 +00:00
|
|
|
|
var result = new DotnetTestCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
|
|
|
.WithRuntime(runtime)
|
|
|
|
|
.ExecuteWithCapturedOutput();
|
|
|
|
|
|
|
|
|
|
result.StdOut
|
|
|
|
|
.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0.", "because .NET 4.6 tests will pass")
|
|
|
|
|
.And.Contain("Passed TestNamespace.VSTestTests.VSTestPassTestDesktop", "because .NET 4.6 tests will pass")
|
|
|
|
|
.And.Contain("Total tests: 3. Passed: 1. Failed: 2. Skipped: 0.", "because netcoreapp1.0 tests will fail")
|
|
|
|
|
.And.Contain("Failed TestNamespace.VSTestTests.VSTestFailTestNetCoreApp", "because netcoreapp1.0 tests will fail");
|
2016-11-01 20:15:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[WindowsOnlyFact]
|
2016-11-02 18:08:20 +00:00
|
|
|
|
public void XunitMultiTFM()
|
2016-11-01 20:15:44 +00:00
|
|
|
|
{
|
2016-11-02 18:44:03 +00:00
|
|
|
|
// Copy VSTestXunitDesktopAndNetCore project in output directory of project dotnet-test.Tests
|
|
|
|
|
string testAppName = "VSTestXunitDesktopAndNetCore";
|
2016-11-01 20:15:44 +00:00
|
|
|
|
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
|
|
|
|
|
|
|
|
|
string testProjectDirectory = testInstance.TestRoot;
|
|
|
|
|
|
2016-11-02 18:44:03 +00:00
|
|
|
|
// Restore project VSTestXunitDesktopAndNetCore
|
2016-11-01 20:15:44 +00:00
|
|
|
|
new RestoreCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
// Call test
|
|
|
|
|
CommandResult result = new DotnetTestCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-11-02 18:08:20 +00:00
|
|
|
|
.ExecuteWithCapturedOutput();
|
2016-11-02 09:37:13 +00:00
|
|
|
|
|
2016-11-02 18:08:20 +00:00
|
|
|
|
// Verify
|
|
|
|
|
// 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");
|
2016-11-01 20:15:44 +00:00
|
|
|
|
|
2016-11-02 18:08:20 +00:00
|
|
|
|
// 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");
|
2016-10-28 14:45:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|