dotnet-installer/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs

80 lines
3.3 KiB
C#
Raw Normal View History

// 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;
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]
public void MStestMultiTFM()
{
// Copy VSTestDesktopAndNetCore project in output directory of project dotnet-test.Tests
string testAppName = "VSTestDesktopAndNetCore";
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
string testProjectDirectory = testInstance.TestRoot;
// Restore project VSTestDesktopAndNetCore
new RestoreCommand()
.WithWorkingDirectory(testProjectDirectory)
.Execute()
.Should()
.Pass();
2016-11-01 16:31:30 +00:00
// Call test
CommandResult result = new DotnetTestCommand()
.WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput();
2016-11-01 16:31:30 +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");
// 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");
}
[WindowsOnlyFact]
public void XunitMultiTFM()
{
// Copy VSTestXunitDesktopAndNetCore project in output directory of project dotnet-test.Tests
string testAppName = "VSTestXunitDesktopAndNetCore";
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
string testProjectDirectory = testInstance.TestRoot;
// Restore project VSTestXunitDesktopAndNetCore
new RestoreCommand()
.WithWorkingDirectory(testProjectDirectory)
.Execute()
.Should()
.Pass();
// Call test
CommandResult result = new DotnetTestCommand()
.WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput();
// 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");
// 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");
}
}
}