@@ -180,6 +180,30 @@ await RetryHelper.RetryAsync(
180180 } , 3 , TimeSpan . FromSeconds ( 5 ) ) ;
181181 }
182182
183+ [ TestMethod ]
184+ public async Task RetryFailedTests_PassingFromFirstTime_UsingOldDotnetTest_MoveFiles_Succeeds ( )
185+ {
186+ string resultDirectory = Path . Combine ( AssetFixture . TargetAssetPath , Guid . NewGuid ( ) . ToString ( "N" ) ) ;
187+
188+ DotnetMuxerResult result = await DotnetCli . RunAsync (
189+ $ "test \" { AssetFixture . TargetAssetPath } \" -- --retry-failed-tests 1 --results-directory \" { resultDirectory } \" ",
190+ AcceptanceFixture . NuGetGlobalPackagesFolder . Path ,
191+ workingDirectory : AssetFixture . TargetAssetPath ) ;
192+
193+ Assert . AreEqual ( ExitCodes . Success , result . ExitCode ) ;
194+
195+ string [ ] logFilesFromInvokeTestingPlatformTask = Directory . GetFiles ( resultDirectory , "RetryFailedTests_*_*.log" , SearchOption . AllDirectories ) ;
196+ Assert . AreEqual ( TargetFrameworks . All . Length , logFilesFromInvokeTestingPlatformTask . Length ) ;
197+ foreach ( string logFile in logFilesFromInvokeTestingPlatformTask )
198+ {
199+ string logFileContents = File . ReadAllText ( logFile ) ;
200+ Assert . Contains ( "Test run summary: Passed!" , logFileContents ) ;
201+ Assert . Contains ( "total: 3" , logFileContents ) ;
202+ Assert . Contains ( "succeeded: 3" , logFileContents ) ;
203+ Assert . Contains ( "Tests suite completed successfully in 1 attempts" , logFileContents ) ;
204+ }
205+ }
206+
183207 public sealed class TestAssetFixture ( ) : TestAssetFixtureBase ( AcceptanceFixture . NuGetGlobalPackagesFolder )
184208 {
185209 public string TargetAssetPath => GetAssetPath ( AssetName ) ;
@@ -202,21 +226,30 @@ public sealed class TestAssetFixture() : TestAssetFixtureBase(AcceptanceFixture.
202226 <OutputType>Exe</OutputType>
203227 <UseAppHost>true</UseAppHost>
204228 <LangVersion>preview</LangVersion>
229+ <GenerateTestingPlatformEntryPoint>false</GenerateTestingPlatformEntryPoint>
230+ <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
231+ <TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
205232 </PropertyGroup>
206233 <ItemGroup>
207234 <PackageReference Include="Microsoft.Testing.Extensions.CrashDump" Version="$MicrosoftTestingPlatformVersion$" />
208235 <PackageReference Include="Microsoft.Testing.Extensions.Retry" Version="$MicrosoftTestingPlatformVersion$" />
209236 <PackageReference Include="Microsoft.Testing.Extensions.TrxReport" Version="$MicrosoftTestingPlatformVersion$" />
237+ <PackageReference Include="Microsoft.Testing.Platform.MSBuild" Version="$MicrosoftTestingPlatformVersion$" />
210238 </ItemGroup>
211239</Project>
212240
241+ #file dotnet.config
242+ [dotnet.test.runner]
243+ name= "VSTest"
244+
213245#file Program.cs
214246using Microsoft.Testing.Extensions;
215247using Microsoft.Testing.Extensions.TrxReport.Abstractions;
216248using Microsoft.Testing.Platform.Builder;
217249using Microsoft.Testing.Platform.Capabilities.TestFramework;
218250using Microsoft.Testing.Platform.Extensions.Messages;
219251using Microsoft.Testing.Platform.Extensions.TestFramework;
252+ using Microsoft.Testing.Platform.MSBuild;
220253using Microsoft.Testing.Platform.Services;
221254
222255public class Program
@@ -230,6 +263,7 @@ public static async Task<int> Main(string[] args)
230263 builder.AddCrashDumpProvider();
231264 builder.AddTrxReportProvider();
232265 builder.AddRetryProvider();
266+ builder.AddMSBuild();
233267 using ITestApplication app = await builder.BuildAsync();
234268 return await app.RunAsync();
235269 }
@@ -270,7 +304,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
270304 string resultDir = Environment.GetEnvironmentVariable("RESULTDIR")!;
271305 bool crash = Environment.GetEnvironmentVariable("CRASH") == "1";
272306
273- if (await TestMethod1(fail, resultDir, crash))
307+ if (TestMethod1(fail, resultDir, crash))
274308 {
275309 await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid,
276310 new TestNode() { Uid = "1", DisplayName = "TestMethod1", Properties = new(PassedTestNodeStateProperty.CachedInstance) }));
@@ -281,7 +315,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
281315 new TestNode() { Uid = "1", DisplayName = "TestMethod1", Properties = new(new FailedTestNodeStateProperty()) }));
282316 }
283317
284- if (await TestMethod2(fail, resultDir))
318+ if (TestMethod2(fail, resultDir))
285319 {
286320 await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid,
287321 new TestNode() { Uid = "2", DisplayName = "TestMethod2", Properties = new(PassedTestNodeStateProperty.CachedInstance) }));
@@ -292,7 +326,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
292326 new TestNode() { Uid = "2", DisplayName = "TestMethod2", Properties = new(new FailedTestNodeStateProperty()) }));
293327 }
294328
295- if (await TestMethod3(fail, resultDir))
329+ if (TestMethod3(fail, resultDir))
296330 {
297331 await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid,
298332 new TestNode() { Uid = "3", DisplayName = "TestMethod3", Properties = new(PassedTestNodeStateProperty.CachedInstance) }));
@@ -306,7 +340,7 @@ public async Task ExecuteRequestAsync(ExecuteRequestContext context)
306340 context.Complete();
307341 }
308342
309- private async Task< bool> TestMethod1(bool fail, string resultDir, bool crash)
343+ private bool TestMethod1(bool fail, string resultDir, bool crash)
310344 {
311345 if (crash)
312346 {
@@ -330,7 +364,7 @@ private async Task<bool> TestMethod1(bool fail, string resultDir, bool crash)
330364 return assert;
331365 }
332366
333- private async Task< bool> TestMethod2(bool fail, string resultDir)
367+ private bool TestMethod2(bool fail, string resultDir)
334368 {
335369 bool envVar = Environment.GetEnvironmentVariable("METHOD2") is null;
336370 System.Console.WriteLine("envVar " + envVar);
@@ -350,7 +384,7 @@ private async Task<bool> TestMethod2(bool fail, string resultDir)
350384 return assert;
351385 }
352386
353- private async Task< bool> TestMethod3(bool fail, string resultDir)
387+ private bool TestMethod3(bool fail, string resultDir)
354388 {
355389 bool envVar = Environment.GetEnvironmentVariable("METHOD3") is null;
356390
0 commit comments