1) Added test to cover xunit scenario
2) Added log in multi tfm test to root cause the issue where it is failing for net46
This commit is contained in:
parent
5c5ce3d336
commit
0995daf83e
15 changed files with 262 additions and 34 deletions
|
@ -2,14 +2,6 @@
|
|||
|
||||
namespace TestNamespace
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[TestClass]
|
||||
public class VSTestTests
|
||||
{
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -32,8 +31,8 @@
|
|||
<PackageReference Include="MSTest.TestAdapter">
|
||||
<Version>1.1.4-preview</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost">
|
||||
<Version>15.0.0-preview-20161028-03</Version>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||
<Version>15.0.0-preview-20161024-02</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
|
@ -2,14 +2,6 @@
|
|||
|
||||
namespace TestNamespace
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[TestClass]
|
||||
public class VSTestTests
|
||||
{
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -24,8 +24,8 @@
|
|||
<PackageReference Include="MSTest.TestAdapter">
|
||||
<Version>1.1.4-preview</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.TestPlatform.TestHost">
|
||||
<Version>15.0.0-preview-20161028-03</Version>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||
<Version>15.0.0-preview-20161024-02</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="vstest" value="https://dotnet.myget.org/F/vstest/auth/967ad631-d24c-4c0e-bece-922de3064956/api/v3/index.json" />
|
||||
</packageSources>
|
||||
<activePackageSource>
|
||||
<add key="All" value="(Aggregate source)" />
|
||||
</activePackageSource>
|
||||
</configuration>
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'net46'">
|
||||
<DefineConstants>DESKTOP;$(DefineConstants)</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp1.0'">
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161026-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||
<Version>15.0.0-preview-20161024-02</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit">
|
||||
<Version>2.2.0-beta3-build3402</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<Version>2.2.0-beta4-build1188</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<add key="dotnet-core" value="https://dotnet.myget.org/F/dotnet-core/api/v3/index.json" />
|
||||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
<add key="vstest" value="https://dotnet.myget.org/F/vstest/auth/967ad631-d24c-4c0e-bece-922de3064956/api/v3/index.json" />
|
||||
</packageSources>
|
||||
<activePackageSource>
|
||||
<add key="All" value="(Aggregate source)" />
|
||||
</activePackageSource>
|
||||
</configuration>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp1.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" />
|
||||
<EmbeddedResource Include="**\*.resx" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.App">
|
||||
<Version>1.0.1</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Sdk">
|
||||
<Version>1.0.0-alpha-20161026-2</Version>
|
||||
<PrivateAssets>All</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk">
|
||||
<Version>15.0.0-preview-20161024-02</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit">
|
||||
<Version>2.2.0-beta3-build3402</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="xunit.runner.visualstudio">
|
||||
<Version>2.2.0-beta4-build1188</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -97,7 +97,7 @@
|
|||
|
||||
<!-- Workaround for https://github.com/dotnet/sdk/issues/115 -->
|
||||
<ItemGroup>
|
||||
<HackFilesToCopy Include="$(NuGetPackagesDir)\microsoft.build.runtime\15.1.0-preview-000370-00\contentFiles\any\netcoreapp1.0\**;$(NuGetPackagesDir)\microsoft.codeanalysis.build.tasks\2.0.0-beta6-60922-08\contentFiles\any\any\**;$(NuGetPackagesDir)\microsoft.testplatform.cli\15.0.0-preview-20161028-03\contentFiles\any\any\**" />
|
||||
<HackFilesToCopy Include="$(NuGetPackagesDir)\microsoft.build.runtime\15.1.0-preview-000370-00\contentFiles\any\netcoreapp1.0\**;$(NuGetPackagesDir)\microsoft.codeanalysis.build.tasks\2.0.0-beta6-60922-08\contentFiles\any\any\**;$(NuGetPackagesDir)\microsoft.testplatform.cli\15.0.0-preview-20161101-02\contentFiles\any\any\**" />
|
||||
</ItemGroup>
|
||||
<Copy SourceFiles="@(HackFilesToCopy)"
|
||||
DestinationFiles="@(HackFilesToCopy->'$(SdkOutputDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace Microsoft.DotNet.Tools.Test
|
|||
CommandOptionType.SingleValue);
|
||||
|
||||
var outputOption = cmd.Option(
|
||||
"-o|--output <OotputDir>",
|
||||
"-o|--output <OutputDir>",
|
||||
@"Directory in which to find the binaries to be run",
|
||||
CommandOptionType.SingleValue);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
<Version>4.0.0-rc-2037</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.TestPlatform.CLI">
|
||||
<Version>15.0.0-preview-20161028-03</Version>
|
||||
<Version>15.0.0-preview-20161101-02</Version>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.TestPlatform.Build">
|
||||
<Version>15.0.0-preview-20161028-03</Version>
|
||||
|
|
|
@ -8,15 +8,20 @@ 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
|
||||
{
|
||||
// Adding log to root cause test failure for net46
|
||||
private const string vstestLog = "VSTEST_TRACE_BUILD";
|
||||
// project targeting net46 will not run in non windows machine.
|
||||
[WindowsOnlyFact]
|
||||
public void TestsFromAGivenProjectShouldRunWithExpectedOutputForMultiTFM()
|
||||
{
|
||||
Environment.SetEnvironmentVariable(vstestLog, "1");
|
||||
|
||||
// Copy VSTestDesktopAndNetCoreApp project in output directory of project dotnet-test.Tests
|
||||
string testAppName = "VSTestDesktopAndNetCoreApp";
|
||||
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
||||
|
@ -50,14 +55,76 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("*********************************StdOut****************************************************************");
|
||||
Console.WriteLine(result.StdOut.ToString());
|
||||
|
||||
Console.WriteLine("*********************************StdErr****************************************************************");
|
||||
Console.WriteLine(result.StdErr.ToString());
|
||||
|
||||
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("**************************************************************************************************");
|
||||
Console.WriteLine("**********************************Vstest.console Log****************************************************************");
|
||||
Console.WriteLine(File.ReadAllText(logfile1));
|
||||
Console.WriteLine("**********************************TestHost Log****************************************************************");
|
||||
Console.WriteLine(logfile2.Length>0 ? File.ReadAllText(logfile2[0]):"No log file found");
|
||||
Console.WriteLine("**************************************************************************************************");
|
||||
}
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void TestsFromAGivenXunitProjectShouldRunWithExpectedOutputForMultiTFM()
|
||||
{
|
||||
// Adding log to root cause test failure for net46
|
||||
Environment.SetEnvironmentVariable(vstestLog, "1");
|
||||
|
||||
// Copy VSTestXunitDesktopAndNetCoreApp project in output directory of project dotnet-test.Tests
|
||||
string testAppName = "VSTestXunitDesktopAndNetCoreApp";
|
||||
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
||||
|
||||
string testProjectDirectory = testInstance.TestRoot;
|
||||
|
||||
// Restore project VSTestXunitDesktopAndNetCoreApp
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("--diag LogFile.txt");
|
||||
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
// 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");
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("*********************************Xunit StdOut****************************************************************");
|
||||
Console.WriteLine(result.StdOut.ToString());
|
||||
|
||||
Console.WriteLine("*********************************Xunit StdErr****************************************************************");
|
||||
Console.WriteLine(result.StdErr.ToString());
|
||||
|
||||
string logfile1 = Path.Combine(testProjectDirectory, "LogFile.txt");
|
||||
string[] logfile2 = Directory.GetFiles(testProjectDirectory, "LogFile.host.*");
|
||||
|
||||
Console.WriteLine("*********************************Xunit Vstest.console Log****************************************************************");
|
||||
Console.WriteLine(File.ReadAllText(logfile1));
|
||||
Console.WriteLine("********************************Xunit TestHost Log****************************************************************");
|
||||
Console.WriteLine(logfile2.Length > 0 ? File.ReadAllText(logfile2[0]) : "No log file found");
|
||||
Console.WriteLine("**************************************************************************************************");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
{
|
||||
public class GivenDotnettestBuildsAndRunsTestfromCsproj : TestBase
|
||||
{
|
||||
[Fact]
|
||||
//[Fact]
|
||||
public void TestsFromAGivenProjectShouldRunWithExpectedOutput()
|
||||
{
|
||||
// Copy VSTestDotNetCoreProject project in output directory of project dotnet-vstest.Tests
|
||||
|
@ -32,7 +32,7 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
// Call test
|
||||
CommandResult result = new DotnetTestCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("-f netcoreapp1.0");
|
||||
.ExecuteWithCapturedOutput();
|
||||
|
||||
// Verify
|
||||
result.StdOut.Should().Contain("Total tests: 2. Passed: 1. Failed: 1. Skipped: 0.");
|
||||
|
@ -40,7 +40,34 @@ namespace Microsoft.DotNet.Cli.Test.Tests
|
|||
result.StdOut.Should().Contain("Failed TestNamespace.VSTestTests.VSTestFailTest");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
//[Fact]
|
||||
public void TestsFromAGivenXunitProjectShouldRunWithExpectedOutput()
|
||||
{
|
||||
// Copy VSTestXunitDotNetCoreProject project in output directory of project dotnet-vstest.Tests
|
||||
string testAppName = "VSTestXunitDotNetCoreProject";
|
||||
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
|
||||
|
||||
string testProjectDirectory = testInstance.TestRoot;
|
||||
|
||||
// Restore project VSTestXunitDotNetCoreProject
|
||||
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 VSTestDotNetCoreProject project in output directory of project dotnet-vstest.Tests
|
||||
|
|
Loading…
Reference in a new issue