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

Commit eb8e0cf

Browse files
Faizan2304Piotr Puszkiewicz
authored and
Piotr Puszkiewicz
committed
Bug fixes (#4810)
* 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
1 parent 3a3ab7e commit eb8e0cf

File tree

12 files changed

+64
-18
lines changed

12 files changed

+64
-18
lines changed

TestAssets/TestProjects/VSTestDesktopAndNetCore/VSTestDesktopAndNetCore.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@
2626
<PrivateAssets>All</PrivateAssets>
2727
</PackageReference>
2828
<PackageReference Include="MSTest.TestFramework">
29-
<Version>1.0.5-preview</Version>
29+
<Version>1.0.6-preview</Version>
3030
</PackageReference>
3131
<PackageReference Include="MSTest.TestAdapter">
32-
<Version>1.1.4-preview</Version>
32+
<Version>1.1.5-preview</Version>
3333
</PackageReference>
3434
<PackageReference Include="Microsoft.NET.Test.Sdk">
35-
<Version>15.0.0-preview-20161024-02</Version>
35+
<Version>15.0.0-preview-20161123-03</Version>
3636
</PackageReference>
3737
</ItemGroup>
3838
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />

TestAssets/TestProjects/VSTestDotNetCore/VSTestDotNetCore.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
<PrivateAssets>All</PrivateAssets>
2020
</PackageReference>
2121
<PackageReference Include="MSTest.TestFramework">
22-
<Version>1.0.5-preview</Version>
22+
<Version>1.0.6-preview</Version>
2323
</PackageReference>
2424
<PackageReference Include="MSTest.TestAdapter">
25-
<Version>1.1.4-preview</Version>
25+
<Version>1.1.5-preview</Version>
2626
</PackageReference>
2727
<PackageReference Include="Microsoft.NET.Test.Sdk">
28-
<Version>15.0.0-preview-20161024-02</Version>
28+
<Version>15.0.0-preview-20161123-03</Version>
2929
</PackageReference>
3030
</ItemGroup>
3131
<Import Project="$(MSBuildExtensionsPath)\Microsoft.CSharp.targets" />

TestAssets/TestProjects/VSTestXunitDesktopAndNetCore/VSTestXunitDesktopAndNetCore.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<PrivateAssets>All</PrivateAssets>
2727
</PackageReference>
2828
<PackageReference Include="Microsoft.NET.Test.Sdk">
29-
<Version>15.0.0-preview-20161024-02</Version>
29+
<Version>15.0.0-preview-20161123-03</Version>
3030
</PackageReference>
3131
<PackageReference Include="xunit">
3232
<Version>2.2.0-beta4-build3444</Version>

TestAssets/TestProjects/VSTestXunitDotNetCore/VSTestXunitDotNetCore.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PrivateAssets>All</PrivateAssets>
2121
</PackageReference>
2222
<PackageReference Include="Microsoft.NET.Test.Sdk">
23-
<Version>15.0.0-preview-20161024-02</Version>
23+
<Version>15.0.0-preview-20161123-03</Version>
2424
</PackageReference>
2525
<PackageReference Include="xunit">
2626
<Version>2.2.0-beta4-build3444</Version>

build/Microsoft.DotNet.Cli.Compile.targets

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898

9999
<!-- Workaround for https://github.com/dotnet/sdk/issues/115 -->
100100
<ItemGroup>
101-
<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\**" />
101+
<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\**" />
102102
</ItemGroup>
103103
<Copy SourceFiles="@(HackFilesToCopy)"
104104
DestinationFiles="@(HackFilesToCopy->'$(SdkOutputDirectory)/%(RecursiveDir)%(Filename)%(Extension)')" />

resources/MSBuildImports/15.0/Microsoft.Common.CrossTargeting.targets/ImportAfter/Microsoft.TestPlatform.CrossTargeting.targets

+11-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@ Copyright (c) .NET Foundation. All rights reserved.
1111
-->
1212
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1313
<PropertyGroup>
14+
<VSTestTaskAssemblyFile Condition="$(VSTestTaskAssemblyFile) == ''">$(MSBuildExtensionsPath)\Microsoft.TestPlatform.Build.dll</VSTestTaskAssemblyFile>
1415
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
1516
</PropertyGroup>
17+
<UsingTask TaskName="Microsoft.TestPlatform.Build.Tasks.BuildLogTask" AssemblyFile="$(VSTestTaskAssemblyFile)" />
1618
<!--
1719
===================================================================================
1820
DispatchToInnerBuildsWithVSTestTarget
@@ -38,7 +40,8 @@ Copyright (c) .NET Foundation. All rights reserved.
3840
<MSBuild Projects="$(MSBuildProjectFile)"
3941
Condition="'$(TargetFrameworks)' != '' "
4042
Targets="$(InnerVSTestTargets)"
41-
Properties="TargetFramework=%(_TargetFramework.Identity);VSTestNoBuild=true">
43+
Properties="TargetFramework=%(_TargetFramework.Identity);VSTestNoBuild=true"
44+
ContinueOnError="true">
4245
<Output ItemName="InnerOutput" TaskParameter="TargetOutputs" />
4346
</MSBuild>
4447
</Target>
@@ -62,11 +65,17 @@ Copyright (c) .NET Foundation. All rights reserved.
6265
=================================================================================
6366
-->
6467
<Target Name="VSTest" >
65-
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="Build" />
68+
<CallTarget Condition="'$(VSTestNoBuild)' != 'true'" Targets="BuildProject" />
6669
<CallTarget Targets="SetVSTestInnerTarget" />
6770
<CallTarget Targets="DispatchToInnerBuildsWithVSTestTarget" />
6871
</Target>
6972

73+
<Target Name="BuildProject">
74+
<Microsoft.TestPlatform.Build.Tasks.BuildLogTask BuildStarted="True" />
75+
<CallTarget Targets="Build" />
76+
<Microsoft.TestPlatform.Build.Tasks.BuildLogTask />
77+
</Target>
78+
7079
<Target Name="SetVSTestInnerTarget" Returns="@(InnerOutput)">
7180
<PropertyGroup Condition="'$(InnerVSTestTargets)' == ''">
7281
<InnerVSTestTargets>VSTest</InnerVSTestTargets>

src/dotnet/commands/dotnet-new/CSharp_Mstest/$projectName$.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
<PrivateAssets>All</PrivateAssets>
2121
</PackageReference>
2222
<PackageReference Include="Microsoft.NET.Test.Sdk">
23-
<Version>15.0.0-preview-20161024-02</Version>
23+
<Version>15.0.0-preview-20161123-03</Version>
2424
</PackageReference>
2525
<PackageReference Include="MSTest.TestAdapter">
26-
<Version>1.1.3-preview</Version>
26+
<Version>1.1.5-preview</Version>
2727
</PackageReference>
2828
<PackageReference Include="MSTest.TestFramework">
29-
<Version>1.0.4-preview</Version>
29+
<Version>1.0.6-preview</Version>
3030
</PackageReference>
3131
</ItemGroup>
3232

src/dotnet/commands/dotnet-new/CSharp_Xunittest/$projectName$.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<PrivateAssets>All</PrivateAssets>
2121
</PackageReference>
2222
<PackageReference Include="Microsoft.NET.Test.Sdk">
23-
<Version>15.0.0-preview-20161024-02</Version>
23+
<Version>15.0.0-preview-20161123-03</Version>
2424
</PackageReference>
2525
<PackageReference Include="xunit">
2626
<Version>2.2.0-beta4-build3444</Version>

src/dotnet/commands/dotnet-test/Program.cs

+2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ public static int Run(string[] args)
2424
Description = "Test Driver for the .NET Platform"
2525
};
2626

27+
cmd.AllowArgumentSeparator = true;
28+
cmd.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
2729
cmd.HelpOption("-h|--help");
2830

2931
var argRoot = cmd.Argument(

src/redist/redist.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
<Version>4.0.0-rc-2048</Version>
3434
</PackageReference>
3535
<PackageReference Include="Microsoft.TestPlatform.CLI">
36-
<Version>15.0.0-preview-20161102-02</Version>
36+
<Version>15.0.0-preview-20161123-03</Version>
3737
</PackageReference>
3838
<PackageReference Include="Microsoft.TestPlatform.Build">
39-
<Version>15.0.0-preview-20161107-06</Version>
39+
<Version>15.0.0-preview-20161123-03</Version>
4040
</PackageReference>
4141
</ItemGroup>
4242
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">

test/dotnet-test.Tests/GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM.cs test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Microsoft.DotNet.Cli.Test.Tests
1212
{
13-
public class GivenDotnetTest3BuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
13+
public class GivenDotnetTestBuildsAndRunsTestFromCsprojForMultipleTFM : TestBase
1414
{
1515
[WindowsOnlyFact(Skip="https://github.com/dotnet/cli/issues/4616")]
1616
public void MStestMultiTFM()

test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTestfromCsproj.cs

+35
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,40 @@ public void TestWillNotBuildTheProjectIfNoBuildArgsIsGiven()
9696
// Verify
9797
result.StdOut.Should().Contain(expectedError);
9898
}
99+
100+
[Fact]
101+
public void TestWillCreateTrxLogger()
102+
{
103+
// Copy VSTestDotNetCore project in output directory of project dotnet-vstest.Tests
104+
string testAppName = "VSTestDotNetCore";
105+
TestInstance testInstance = TestAssetsManager.CreateTestInstance(testAppName);
106+
107+
string testProjectDirectory = testInstance.TestRoot;
108+
109+
// Restore project VSTestDotNetCore
110+
new RestoreCommand()
111+
.WithWorkingDirectory(testProjectDirectory)
112+
.Execute()
113+
.Should()
114+
.Pass();
115+
116+
string trxLoggerDirectory = Path.Combine(testProjectDirectory, "TestResults");
117+
118+
// Delete trxLoggerDirectory if it exist
119+
if(Directory.Exists(trxLoggerDirectory))
120+
{
121+
Directory.Delete(trxLoggerDirectory, true);
122+
}
123+
124+
// Call test with logger enable
125+
CommandResult result = new DotnetTestCommand()
126+
.WithWorkingDirectory(testProjectDirectory)
127+
.ExecuteWithCapturedOutput("--logger:trx");
128+
129+
// Verify
130+
String[] trxFiles = Directory.GetFiles(trxLoggerDirectory, "*.trx");
131+
Assert.Equal(1, trxFiles.Length);
132+
result.StdOut.Should().Contain(trxFiles[0]);
133+
}
99134
}
100135
}

0 commit comments

Comments
 (0)