diff --git a/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/Tests.cs b/TestAssets/TestProjects/VSTestDesktopAndNetCore/Tests.cs similarity index 74% rename from TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/Tests.cs rename to TestAssets/TestProjects/VSTestDesktopAndNetCore/Tests.cs index f242df270..6b1329249 100644 --- a/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/Tests.cs +++ b/TestAssets/TestProjects/VSTestDesktopAndNetCore/Tests.cs @@ -2,14 +2,6 @@ namespace TestNamespace { - public class Program - { - public static void Main(string[] args) - { - - } - } - [TestClass] public class VSTestTests { @@ -23,18 +15,18 @@ namespace TestNamespace { Assert.Fail(); } - - #if DESKTOP - [TestMethod] + +#if DESKTOP + [TestMethod] public void VSTestPassTestDesktop() { } - #else - [TestMethod] +#else + [TestMethod] public void VSTestFailTestNetCoreApp() { Assert.Fail(); } - #endif +#endif } } \ No newline at end of file diff --git a/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/VSTestDesktopAndNetCoreApp.csproj b/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj similarity index 70% rename from TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/VSTestDesktopAndNetCoreApp.csproj rename to TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj index 9fc218a6f..94314c1d8 100644 --- a/TestAssets/TestProjects/VSTestDesktopAndNetCoreApp/VSTestDesktopAndNetCoreApp.csproj +++ b/TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj @@ -1,12 +1,11 @@ - - + Exe - net46 + net46;netcoreapp1.0 - + DESKTOP;$(DefineConstants) @@ -14,7 +13,7 @@ - + 1.0.1 @@ -26,14 +25,14 @@ 1.0.0-alpha-20161026-2 All - + 1.0.5-preview - + 1.1.4-preview - - 15.0.0-preview-20161028-03 + + 15.0.0-preview-20161024-02 diff --git a/TestAssets/TestProjects/VSTestDotNetCoreProject/Tests.cs b/TestAssets/TestProjects/VSTestDotNetCore/Tests.cs similarity index 75% rename from TestAssets/TestProjects/VSTestDotNetCoreProject/Tests.cs rename to TestAssets/TestProjects/VSTestDotNetCore/Tests.cs index afb3b28a2..e9b847369 100644 --- a/TestAssets/TestProjects/VSTestDotNetCoreProject/Tests.cs +++ b/TestAssets/TestProjects/VSTestDotNetCore/Tests.cs @@ -2,14 +2,6 @@ namespace TestNamespace { - public class Program - { - public static void Main(string[] args) - { - - } - } - [TestClass] public class VSTestTests { diff --git a/TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj b/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj similarity index 64% rename from TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj rename to TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj index e55de3925..b0f9dc3d9 100644 --- a/TestAssets/TestProjects/VSTestDotNetCoreProject/VSTestDotNetCoreProject.csproj +++ b/TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj @@ -1,10 +1,9 @@ - - + Exe - netcoreapp1.0 + netcoreapp1.0 @@ -19,14 +18,14 @@ 1.0.0-alpha-20161029-1 All - + 1.0.5-preview - + 1.1.4-preview - - 15.0.0-preview-20161028-03 + + 15.0.0-preview-20161024-02 diff --git a/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/Nuget.config b/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/Nuget.config new file mode 100644 index 000000000..1b7dbc159 --- /dev/null +++ b/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/Nuget.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/UnitTest1.cs b/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/UnitTest1.cs new file mode 100644 index 000000000..b77a42021 --- /dev/null +++ b/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/UnitTest1.cs @@ -0,0 +1,32 @@ +using System; +using Xunit; + +namespace TestNamespace +{ + public class VSTestXunitTests + { + [Fact] + public void VSTestXunitPassTest() + { + } + + [Fact] + public void VSTestXunitFailTest() + { + Assert.Equal(1, 2); + } + +#if DESKTOP + [Fact] + public void VSTestXunitPassTestDesktop() + { + } +#else + [Fact] + public void VSTestXunitFailTestNetCoreApp() + { + Assert.Equal(1, 2); + } +#endif + } +} diff --git a/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj b/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj new file mode 100644 index 000000000..9b408113c --- /dev/null +++ b/TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj @@ -0,0 +1,40 @@ + + + + + Exe + net46;netcoreapp1.0 + + + + DESKTOP;$(DefineConstants) + + + + + + + + + 1.0.1 + + + + + + 1.0.0-alpha-20161026-2 + All + + + 15.0.0-preview-20161024-02 + + + 2.2.0-beta3-build3402 + + + 2.2.0-beta4-build1188 + + + + + diff --git a/TestAssets/TestProjects/VSTestXunitDotNetCore/Nuget.config b/TestAssets/TestProjects/VSTestXunitDotNetCore/Nuget.config new file mode 100644 index 000000000..1b7dbc159 --- /dev/null +++ b/TestAssets/TestProjects/VSTestXunitDotNetCore/Nuget.config @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/TestAssets/TestProjects/VSTestXunitDotNetCore/UnitTest1.cs b/TestAssets/TestProjects/VSTestXunitDotNetCore/UnitTest1.cs new file mode 100644 index 000000000..5ed55618b --- /dev/null +++ b/TestAssets/TestProjects/VSTestXunitDotNetCore/UnitTest1.cs @@ -0,0 +1,19 @@ +using System; +using Xunit; + +namespace TestNamespace +{ + public class VSTestXunitTests + { + [Fact] + public void VSTestXunitPassTest() + { + } + + [Fact] + public void VSTestXunitFailTest() + { + Assert.Equal(1, 2); + } + } +} diff --git a/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj b/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj new file mode 100644 index 000000000..ef33981c1 --- /dev/null +++ b/TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj @@ -0,0 +1,34 @@ + + + + + Exe + netcoreapp1.0 + + + + + + + + + + 1.0.1 + + + 1.0.0-alpha-20161026-2 + All + + + 15.0.0-preview-20161024-02 + + + 2.2.0-beta3-build3402 + + + 2.2.0-beta4-build1188 + + + + + diff --git a/build/Microsoft.DotNet.Cli.Compile.targets b/build/Microsoft.DotNet.Cli.Compile.targets index c2e875fd0..cc79410e7 100644 --- a/build/Microsoft.DotNet.Cli.Compile.targets +++ b/build/Microsoft.DotNet.Cli.Compile.targets @@ -97,7 +97,7 @@ - + diff --git a/src/redist/redist.csproj b/src/redist/redist.csproj index e6f051f25..59fd617c9 100644 --- a/src/redist/redist.csproj +++ b/src/redist/redist.csproj @@ -33,10 +33,10 @@ 4.0.0-rc-2037 - 15.0.0-preview-20161005-01 + 15.0.0-preview-20161102-02 - 15.0.0-preview-20161005-01 + 15.0.0-preview-20161028-03 diff --git a/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs b/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs index 23f7593e6..3ef4dc3af 100644 --- a/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs +++ b/test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs @@ -2,62 +2,78 @@ // 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; 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. - [WindowsOnlyFact(Skip="https://github.com/dotnet/cli/issues/4526")] - public void TestsFromAGivenProjectShouldRunWithExpectedOutputForMultiTFM() + [WindowsOnlyFact] + public void MStestMultiTFM() { - // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestDesktopAndNetCoreApp"; + // 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 VSTestDesktopAndNetCoreApp + // Restore project VSTestDesktopAndNetCore new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() .Should() .Pass(); - // Call test3 + // Call test CommandResult result = new DotnetTestCommand() .WithWorkingDirectory(testProjectDirectory) - .ExecuteWithCapturedOutput("--diag LogFile.txt"); + .ExecuteWithCapturedOutput(); // Verify // for target framework net46 - try - { - result.StdOut.Should().Contain("Total tests: 3. Passed: 2. Failed: 1. Skipped: 0."); - result.StdOut.Should().Contain("Passed TestNamespace.VSTestTests.VSTestPassTestDesktop"); - } - catch - { - string logfile1 = Path.Combine(testProjectDirectory,"LogFile.txt"); - string[] logfile2 = Directory.GetFiles(testProjectDirectory, "LogFile.host.*"); - - System.Console.WriteLine("**********************************Vstest.console Log****************************************************************"); - System.Console.WriteLine(File.ReadAllText(logfile1)); - System.Console.WriteLine("**********************************TestHost Log****************************************************************"); - System.Console.WriteLine(logfile2.Length>0 ? File.ReadAllText(logfile2[0]):"No log file found"); - System.Console.WriteLine("**************************************************************************************************"); - } + 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"); + 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"); } } } diff --git a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs index df280b4ca..37f527585 100644 --- a/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs +++ b/test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs @@ -13,16 +13,16 @@ namespace Microsoft.DotNet.Cli.Test.Tests { public class GivenDotnettestBuildsAndRunsTestfromCsproj : TestBase { - //[Fact] - public void TestsFromAGivenProjectShouldRunWithExpectedOutput() + [Fact] + public void MSTestSingleTFM() { - // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestDotNetCoreProject"; + // Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests + string testAppName = "VSTestDotNetCore"; TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName); string testProjectDirectory = testInstance.TestRoot; - // Restore project VSTestDotNetCoreProject + // Restore project VSTestDotNetCore new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() @@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests // Call test CommandResult result = new DotnetTestCommand() .WithWorkingDirectory(testProjectDirectory) - .ExecuteWithCapturedOutput("/p:TargetFramework=netcoreapp1.0"); + .ExecuteWithCapturedOutput(); // Verify result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0."); @@ -40,16 +40,43 @@ namespace Microsoft.DotNet.Cli.Test.Tests result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest"); } - //[Fact] - public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven() + [Fact] + public void XunitSingleTFM() { - // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestDotNetCoreProject"; + // Copy VSTestXunitDotNetCore project in output directory of project dotnet-vstest.Tests + string testAppName = "VSTestXunitDotNetCore"; TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName); string testProjectDirectory = testInstance.TestRoot; - // Restore project VSTestDotNetCoreProject + // Restore project VSTestXunitDotNetCore + new RestoreCommand() + .WithWorkingDirectory(testProjectDirectory) + .Execute() + .Should() + .Pass(); + + // Call test + CommandResult result = new DotnetTestCommand() + .WithWorkingDirectory(testProjectDirectory) + .ExecuteWithCapturedOutput(); + + // Verify + result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0."); + result.StdOut.Should().Contain("Passed TestNamespace.VSTestXunitTests.VSTestXunitPassTest"); + result.StdOut.Should().Contain("Failed TestNamespace.VSTestXunitTests.VSTestXunitFailTest"); + } + + [Fact] + public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven() + { + // Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests + string testAppName = "VSTestDotNetCore"; + TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName); + + string testProjectDirectory = testInstance.TestRoot; + + // Restore project VSTestDotNetCore new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() @@ -58,10 +85,10 @@ namespace Microsoft.DotNet.Cli.Test.Tests string configuration = Environment.GetEnvironmentVariable("CONFIGURATION") ?? "Debug"; string expectedError = Path.Combine(testProjectDirectory, "bin", - configuration, "netcoreapp1.0", "VSTestDotNetCoreProject.dll"); + configuration, "netcoreapp1.0", "VSTestDotNetCore.dll"); expectedError = "The test source file " + "\"" + expectedError + "\"" + " provided was not found."; - // Call test3 + // Call test CommandResult result = new DotnetTestCommand() .WithWorkingDirectory(testProjectDirectory) .ExecuteWithCapturedOutput("--noBuild"); diff --git a/test/dotnet-vstest.Tests/VSTestTests.cs b/test/dotnet-vstest.Tests/VSTestTests.cs index 29c1cdca3..addfa6afa 100644 --- a/test/dotnet-vstest.Tests/VSTestTests.cs +++ b/test/dotnet-vstest.Tests/VSTestTests.cs @@ -13,23 +13,23 @@ namespace Microsoft.DotNet.Cli.VSTest.Tests { public class VSTestTests : TestBase { - [Fact(Skip="https://github.com/dotnet/cli/issues/4526")] + [Fact] public void TestsFromAGivenContainerShouldRunWithExpectedOutput() { - // Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests - string testAppName = "VSTestDotNetCoreProject"; + // Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests + string testAppName = "VSTestDotNetCore"; TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName); string testProjectDirectory = testInstance.TestRoot; - // Restore project VSTestDotNetCoreProject + // Restore project VSTestDotNetCore new RestoreCommand() .WithWorkingDirectory(testProjectDirectory) .Execute() .Should() .Pass(); - // Build project VSTestDotNetCoreProject + // Build project VSTestDotNetCore new BuildCommand() .WithWorkingDirectory(testProjectDirectory) .Execute()