1) Added support to run test from test3 verb for the project targeting multiple TFM

2) Added test to address above change
3) Crossgen were creating problem for full CLR built assemblies. Removed All those assembly from Crossgen list.
4) Removed the line of code which were deleting Extensions folder under sdk folder as this folder contain trx logger dlls
This commit is contained in:
Faizan Ahmad 2016-10-25 20:10:18 +05:30
parent a0ee0f6d94
commit 33caa408a1
8 changed files with 243 additions and 9 deletions

View file

@ -0,0 +1,48 @@
// 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 Xunit;
using FluentAssertions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Cli.Utils;
using System.Runtime.InteropServices;
namespace Microsoft.DotNet.Cli.Test3.Tests
{
public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
{
[Fact]
public void TestsFromAGivenProjectShouldRunWithExpectedOutputForMultiTFM()
{
// project targeting net46 will not run in non windows machine.
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
string testAppName = "VSTestDesktopAndNetCoreApp";
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
string testProjectDirectory = testInstance.TestRoot;
// Restore project VSTestDotNetCoreProject
new Restore3Command()
.WithWorkingDirectory(testProjectDirectory)
.Execute()
.Should()
.Pass();
// Call test3
CommandResult result = new Test3Command().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.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");
}
}
}
}

View file

@ -6,6 +6,7 @@ using Xunit;
using FluentAssertions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Cli.Utils;
using System.IO;
namespace Microsoft.DotNet.Cli.Test3.Tests
{
@ -28,12 +29,38 @@ namespace Microsoft.DotNet.Cli.Test3.Tests
.Pass();
// Call test3
CommandResult result = new Test3Command().WithWorkingDirectory(testProjectDirectory).ExecuteWithCapturedOutput("/p:TargetFramework=netcoreapp1.0");
CommandResult result = new Test3Command().WithWorkingDirectory(testProjectDirectory).ExecuteWithCapturedOutput("--framework netcoreapp1.0");
// Verify
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTest");
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
}
[Fact]
public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
{
// Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
string testAppName = "VSTestDotNetCoreProject";
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
string testProjectDirectory = testInstance.TestRoot;
// Restore project VSTestDotNetCoreProject
new Restore3Command()
.WithWorkingDirectory(testProjectDirectory)
.Execute()
.Should()
.Pass();
string expectedError = Path.Combine(testProjectDirectory, @"bin\Debug\netcoreapp1.0\VSTestDotNetCoreProject.dll");
expectedError = "The test source file " + "\""+ expectedError + "\"" + " provided was not found.";
// Call test3
CommandResult result = new Test3Command().WithWorkingDirectory(testProjectDirectory).ExecuteWithCapturedOutput("--noBuild");
// Verify
result.StdOut.Should().Contain(expectedError);
}
}
}