Skip to content

Commit 38db961

Browse files
committed
Add test for MTP Retry feature
1 parent 2fc1537 commit 38db961

File tree

5 files changed

+61
-4
lines changed

5 files changed

+61
-4
lines changed

eng/Versions.props

-4
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@
174174
<MicrosoftTestPlatformCLIPackageVersion>17.14.0-preview-25157-01</MicrosoftTestPlatformCLIPackageVersion>
175175
<MicrosoftTestPlatformBuildPackageVersion>17.14.0-preview-25157-01</MicrosoftTestPlatformBuildPackageVersion>
176176
</PropertyGroup>
177-
<PropertyGroup>
178-
<!-- Dependencies from https://github.com/Microsoft/testfx -->
179-
<MicrosoftTestingPlatformVersion>1.5.0-preview.24602.2</MicrosoftTestingPlatformVersion>
180-
</PropertyGroup>
181177
<PropertyGroup>
182178
<!-- Dependencies from https://github.com/dotnet/roslyn-analyzers -->
183179
<MicrosoftCodeAnalysisNetAnalyzersVersion>10.0.0-preview.25155.1</MicrosoftCodeAnalysisNetAnalyzersVersion>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />
3+
4+
<PropertyGroup>
5+
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
6+
<OutputType>Exe</OutputType>
7+
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --retry-failed-tests 3</TestingPlatformCommandLineArguments>
8+
<EnableMSTestRunner>true</EnableMSTestRunner>
9+
</PropertyGroup>
10+
11+
<ItemGroup>
12+
<PackageReference Include="MSTest" Version="$(MSTestVersion)" />
13+
<PackageReference Include="Microsoft.Testing.Extensions.Retry" Version="$(MicrosoftTestingPlatformVersion)" />
14+
</ItemGroup>
15+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright (c) .NET Foundation and contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Linq;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
8+
[TestClass]
9+
public class TestClass1
10+
{
11+
[TestMethod]
12+
public void TestMethod1()
13+
{
14+
if (Environment.GetCommandLineArgs().Any(arg => arg.Contains("Retries") && !arg.EndsWith("2")))
15+
{
16+
Assert.Fail("Failing...");
17+
}
18+
}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[dotnet.test:runner]
2+
name= "Microsoft.Testing.Platform"

test/dotnet-test.Tests/GivenDotnetTestBuildsAndRunsTests.cs

+25
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,31 @@ public void RunTestProjectWithNoTests_ShouldReturnExitCodeGenericFailure(string
3636
result.ExitCode.Should().Be(ExitCode.GenericFailure);
3737
}
3838

39+
[InlineData(TestingConstants.Debug)]
40+
[InlineData(TestingConstants.Release)]
41+
[Theory]
42+
public void RunTestProjectWithWithRetryFeature_ShouldSucceed(string configuration)
43+
{
44+
TestAsset testInstance = _testAssetsManager.CopyTestAsset("TestAppSimpleWithRetry", Guid.NewGuid().ToString())
45+
.WithSource();
46+
47+
CommandResult result = new DotnetTestCommand(Log, disableNewOutput: false)
48+
.WithWorkingDirectory(testInstance.Path)
49+
.Execute(TestingPlatformOptions.ConfigurationOption.Name, configuration);
50+
51+
if (!TestContext.IsLocalized())
52+
{
53+
result.StdOut
54+
.Should().Contain("Test run summary: Passed!")
55+
.And.Contain("total: 1")
56+
.And.Contain("succeeded: 1")
57+
.And.Contain("failed: 0")
58+
.And.Contain("skipped: 0");
59+
}
60+
61+
result.ExitCode.Should().Be(ExitCode.Success);
62+
}
63+
3964
[InlineData(TestingConstants.Debug)]
4065
[InlineData(TestingConstants.Release)]
4166
[Theory]

0 commit comments

Comments
 (0)