Skip to content

Commit 9bfcbf7

Browse files
committed
Add test
1 parent 00ca8b7 commit 9bfcbf7

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/RetryFailedTestsTests.cs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,18 @@ await RetryHelper.RetryAsync(
178178
}, 3, TimeSpan.FromSeconds(5));
179179
}
180180

181+
[TestMethod]
182+
[DynamicData(nameof(TargetFrameworks.All), typeof(TargetFrameworks))]
183+
public async Task RetryFailedTests_PassingFromFirstTime_UsingOldDotnetTest_MoveFiles_Succeeds(string tfm)
184+
{
185+
DotnetMuxerResult result = await DotnetCli.RunAsync(
186+
$"test \"{AssetFixture.TargetAssetPath}\" -- --retry-failed-tests 1",
187+
AcceptanceFixture.NuGetGlobalPackagesFolder.Path,
188+
workingDirectory: AssetFixture.TargetAssetPath);
189+
190+
Assert.AreEqual(ExitCodes.Success, result.ExitCode);
191+
}
192+
181193
public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.NuGetGlobalPackagesFolder)
182194
{
183195
public string TargetAssetPath => GetAssetPath(AssetName);
@@ -200,21 +212,29 @@ public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.
200212
<OutputType>Exe</OutputType>
201213
<UseAppHost>true</UseAppHost>
202214
<LangVersion>preview</LangVersion>
215+
<GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>
216+
<TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
203217
</PropertyGroup>
204218
<ItemGroup>
205219
<PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="$MicrosoftTestingPlatformVersion$" />
206220
<PackageReference Include="Microsoft.Testing.Extensions.Retry" Version="$MicrosoftTestingPlatformVersion$" />
207221
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$MicrosoftTestingPlatformVersion$" />
222+
<PackageReference Include="Microsoft.Testing.Platform.MSBuild" Version="$MicrosoftTestingPlatformVersion$" />
208223
</ItemGroup>
209224
</Project>
210225
226+
#file dotnet.config
227+
[dotnet.test.runner]
228+
name= "VSTest"
229+
211230
#file Program.cs
212231
using Microsoft.Testing.Extensions;
213232
using Microsoft.Testing.Extensions.TrxReport.Abstractions;
214233
using Microsoft.Testing.Platform.Builder;
215234
using Microsoft.Testing.Platform.Capabilities.TestFramework;
216235
using Microsoft.Testing.Platform.Extensions.Messages;
217236
using Microsoft.Testing.Platform.Extensions.TestFramework;
237+
using Microsoft.Testing.Platform.MSBuild;
218238
using Microsoft.Testing.Platform.Services;
219239
220240
public class Program
@@ -228,6 +248,7 @@ public static async Task<int> Main(string[] args)
228248
builder.AddCrashDumpProvider();
229249
builder.AddTrxReportProvider();
230250
builder.AddRetryProvider();
251+
builder.AddMSBuild();
231252
using ITestApplication app = await builder.BuildAsync();
232253
return await app.RunAsync();
233254
}
@@ -268,7 +289,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
268289
string resultDir = Environment.GetEnvironmentVariable("RESULTDIR")!;
269290
bool crash = Environment.GetEnvironmentVariable("CRASH") == "1";
270291
271-
if (await TestMethod1(fail, resultDir, crash))
292+
if (TestMethod1(fail, resultDir, crash))
272293
{
273294
await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid,
274295
new TestNode() { Uid = "1", DisplayName = "TestMethod1", Properties = new(PassedTestNodeStateProperty.CachedInstance) }));
@@ -279,7 +300,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
279300
new TestNode() { Uid = "1", DisplayName = "TestMethod1", Properties = new(new FailedTestNodeStateProperty()) }));
280301
}
281302
282-
if (await TestMethod2(fail, resultDir))
303+
if (TestMethod2(fail, resultDir))
283304
{
284305
await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid,
285306
new TestNode() { Uid = "2", DisplayName = "TestMethod2", Properties = new(PassedTestNodeStateProperty.CachedInstance) }));
@@ -290,7 +311,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
290311
new TestNode() { Uid = "2", DisplayName = "TestMethod2", Properties = new(new FailedTestNodeStateProperty()) }));
291312
}
292313
293-
if (await TestMethod3(fail, resultDir))
314+
if (TestMethod3(fail, resultDir))
294315
{
295316
await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid,
296317
new TestNode() { Uid = "3", DisplayName = "TestMethod3", Properties = new(PassedTestNodeStateProperty.CachedInstance) }));
@@ -304,7 +325,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
304325
context.Complete();
305326
}
306327
307-
private async Task<bool> TestMethod1(bool fail, string resultDir, bool crash)
328+
private bool TestMethod1(bool fail, string resultDir, bool crash)
308329
{
309330
if (crash)
310331
{
@@ -328,7 +349,7 @@ private async Task<bool> TestMethod1(bool fail, string resultDir, bool crash)
328349
return assert;
329350
}
330351
331-
private async Task<bool> TestMethod2(bool fail, string resultDir)
352+
private bool TestMethod2(bool fail, string resultDir)
332353
{
333354
bool envVar = Environment.GetEnvironmentVariable("METHOD2") is null;
334355
System.Console.WriteLine("envVar " + envVar);
@@ -348,7 +369,7 @@ private async Task<bool> TestMethod2(bool fail, string resultDir)
348369
return assert;
349370
}
350371
351-
private async Task<bool> TestMethod3(bool fail, string resultDir)
372+
private bool TestMethod3(bool fail, string resultDir)
352373
{
353374
bool envVar = Environment.GetEnvironmentVariable("METHOD3") is null;
354375

0 commit comments

Comments
 (0)