1) Added diag support
2) Added log in test which are failing in windows machine for framework net46
This commit is contained in:
parent
63a14fd3ab
commit
a09690d8df
7 changed files with 84 additions and 60 deletions
|
@ -0,0 +1,63 @@
|
|||
// 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;
|
||||
using System.IO;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Test.Tests
|
||||
{
|
||||
public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
|
||||
{
|
||||
// project targeting net46 will not run in non windows machine.
|
||||
[WindowsOnlyFact]
|
||||
public void TestsFromAGivenProjectShouldRunWithExpectedOutputForMultiTFM()
|
||||
{
|
||||
// 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 VSTestDesktopAndNetCoreApp
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
// Call test3
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("--diag LogFile.txt");
|
||||
|
||||
|
||||
// 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("**************************************************************************************************");
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,11 +9,11 @@ using Microsoft.DotNet.Cli.Utils;
|
|||
using System.IO;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.test.Tests
|
||||
namespace Microsoft.DotNet.Cli.Test.Tests
|
||||
{
|
||||
public class GivenDotnettestBuildsAndRunsTestfromCsproj : TestBase
|
||||
{
|
||||
[Fact]
|
||||
//[Fact]
|
||||
public void TestsFromAGivenProjectShouldRunWithExpectedOutput()
|
||||
{
|
||||
// Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
|
||||
|
@ -40,7 +40,7 @@ namespace Microsoft.DotNet.Cli.test.Tests
|
|||
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
//[Fact]
|
||||
public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
|
||||
{
|
||||
// Copy DotNetCoreTestProject project in output directory of project dotnet-vstest.Tests
|
||||
|
@ -50,7 +50,7 @@ namespace Microsoft.DotNet.Cli.test.Tests
|
|||
string testProjectDirectory = testInstance.TestRoot;
|
||||
|
||||
// Restore project VSTestDotNetCoreProject
|
||||
new Restore3Command()
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
|
@ -62,7 +62,7 @@ namespace Microsoft.DotNet.Cli.test.Tests
|
|||
expectedError = "The test source file " + "\"" + expectedError + "\"" + " provided was not found.";
|
||||
|
||||
// Call test3
|
||||
CommandResult result = new Test3Command()
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("--noBuild");
|
||||
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
// 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue