Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Bug fixes (#4810)
Browse files Browse the repository at this point in the history
* Bug fixes

* Nitpick

* -Fixed failed tests
-Added test to cover trx logger scenario.

* Fix for issue microsoft/vstest#241

* Fix for failed test. We have taken fix where dotnet test will return nonzero if test fails. In multi TFM scenario if test fails it termates the whole process as dotnet test is returning 1. As a fix of this we should continue if some test fails for next TFM

* Bump Microsoft.Testplatform.CLI and Microsoft.NET.Test.Sdk version
  • Loading branch information
Faizan2304 authored and Piotr Puszkiewicz committed Nov 24, 2016
1 parent 3a3ab7e commit eb8e0cf
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>1.0.5-preview</Version>
<Version>1.0.6-preview</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>1.1.4-preview</Version>
<Version>1.1.5-preview</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161024-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>1.0.5-preview</Version>
<Version>1.0.6-preview</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>1.1.4-preview</Version>
<Version>1.1.5-preview</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161024-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161024-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
<PackageReference Include="xunit">
<Version>2.2.0-beta4-build3444</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161024-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
<PackageReference Include="xunit">
<Version>2.2.0-beta4-build3444</Version>
Expand Down
2 changes: 1 addition & 1 deletion build/Microsoft.DotNet.Cli.Compile.targets
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,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-20161102-02\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-20161123-03\contentFiles\any\any\**" />
</ItemGroup>
<Copy SourceFiles="@(HackFilesToCopy)"
DestinationFiles="@(HackFilesToCopy->'$(SdkOutputDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ Copyright (c) .NET Foundation. All rights reserved.
-->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VSTestTaskAssemblyFile Condition="$(VSTestTaskAssemblyFile) == ''">$(MSBuildExtensionsPath)\Microsoft.TestPlatform.Build.dll</VSTestTaskAssemblyFile>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.BuildLogTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
<!--
===================================================================================
DispatchToInnerBuildsWithVSTestTarget
Expand All @@ -38,7 +40,8 @@ Copyright (c) .NET Foundation. All rights reserved.
<MSBuild Projects="$(MSBuildProjectFile)"
Condition="'$(TargetFrameworks)' != '' "
Targets="$(InnerVSTestTargets)"
Properties="TargetFramework=%(_TargetFramework.Identity);VSTestNoBuild=true">
Properties="TargetFramework=%(_TargetFramework.Identity);VSTestNoBuild=true"
ContinueOnError="true">
<Output ItemName="InnerOutput" TaskParameter="TargetOutputs" />
</MSBuild>
</Target>
Expand All @@ -62,11 +65,17 @@ Copyright (c) .NET Foundation. All rights reserved.
=================================================================================
-->
<Target Name="VSTest" >
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="Build" />
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="BuildProject" />
<CallTarget Targets="SetVSTestInnerTarget" />
<CallTarget Targets="DispatchToInnerBuildsWithVSTestTarget" />
</Target>

<Target Name="BuildProject">
<Microsoft.TestPlatform.Build.Tasks.BuildLogTask BuildStarted="True" />
<CallTarget Targets="Build" />
<Microsoft.TestPlatform.Build.Tasks.BuildLogTask />
</Target>

<Target Name="SetVSTestInnerTarget" Returns="@(InnerOutput)">
<PropertyGroup Condition="'$(InnerVSTestTargets)' == ''">
<InnerVSTestTargets>VSTest</InnerVSTestTargets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161024-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
<PackageReference Include="MSTest.TestAdapter">
<Version>1.1.3-preview</Version>
<Version>1.1.5-preview</Version>
</PackageReference>
<PackageReference Include="MSTest.TestFramework">
<Version>1.0.4-preview</Version>
<Version>1.0.6-preview</Version>
</PackageReference>
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk">
<Version>15.0.0-preview-20161024-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
<PackageReference Include="xunit">
<Version>2.2.0-beta4-build3444</Version>
Expand Down
2 changes: 2 additions & 0 deletions src/dotnet/commands/dotnet-test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public static int Run(string[] args)
Description = "Test Driver for the .NET Platform"
};

cmd.AllowArgumentSeparator = true;
cmd.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
cmd.HelpOption("-h|--help");

var argRoot = cmd.Argument(
Expand Down
4 changes: 2 additions & 2 deletions src/redist/redist.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
<Version>4.0.0-rc-2048</Version>
</PackageReference>
<PackageReference Include="Microsoft.TestPlatform.CLI">
<Version>15.0.0-preview-20161102-02</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
<PackageReference Include="Microsoft.TestPlatform.Build">
<Version>15.0.0-preview-20161107-06</Version>
<Version>15.0.0-preview-20161123-03</Version>
</PackageReference>
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Microsoft.DotNet.Cli.Test.Tests
{
public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
public class GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
{
[WindowsOnlyFact(Skip="https://github.com/dotnet/cli/issues/4616")]
public void MStestMultiTFM()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,40 @@ public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
// Verify
result.StdOut.Should().Contain(expectedError);
}

[Fact]
public void TestWillCreateTrxLogger()
{
// 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()
.Should()
.Pass();

string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TestResults");

// Delete trxLoggerDirectory if it exist
if(Directory.Exists(trxLoggerDirectory))
{
Directory.Delete(trxLoggerDirectory, true);
}

// Call test with logger enable
CommandResult result = new DotnetTestCommand()
.WithWorkingDirectory(testProjectDirectory)
.ExecuteWithCapturedOutput("--logger:trx");

// Verify
String[] trxFiles = Directory.GetFiles(trxLoggerDirectory, "*.trx");
Assert.Equal(1, trxFiles.Length);
result.StdOut.Should().Contain(trxFiles[0]);
}
}
}

0 comments on commit eb8e0cf

Please sign in to comment.