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
|
|
|
|
|
{
|
|
|
|
|
// project targeting net46 will not run in non windows machine.
|
2016-11-01 16:31:30 +00:00
|
|
|
|
[WindowsOnlyFact]
|
2016-11-02 18:08:20 +00:00
|
|
|
|
public void MStestMultiTFM()
|
2016-10-28 14:45:38 +00:00
|
|
|
|
{
|
2016-11-02 18:44:03 +00:00
|
|
|
|
// Copy VSTestDesktopAndNetCore project in output directory of project dotnet-test.Tests
|
|
|
|
|
string testAppName = "VSTestDesktopAndNetCore";
|
2016-10-28 14:45:38 +00:00
|
|
|
|
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
|
|
|
|
|
|
|
|
|
string testProjectDirectory = testInstance.TestRoot;
|
|
|
|
|
|
2016-11-02 18:44:03 +00:00
|
|
|
|
// Restore project VSTestDesktopAndNetCore
|
2016-10-28 14:45:38 +00:00
|
|
|
|
new RestoreCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
2016-11-01 16:31:30 +00:00
|
|
|
|
// Call test
|
2016-10-28 14:45:38 +00:00
|
|
|
|
CommandResult result = new DotnetTestCommand()
|
|
|
|
|
.WithWorkingDirectory(testProjectDirectory)
|
2016-11-02 18:08:20 +00:00
|
|
|
|
.ExecuteWithCapturedOutput();
|
2016-11-01 16:31:30 +00:00
|
|
|
|
|
2016-11-01 20:15:44 +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.VSTestTests.VSTestPassTestDesktop");
|
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.VSTestTests.VSTestFailTestNetCoreApp");
|
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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|