Skip to content

Microsoft.Testing.Extensions.Retry can't move files from TestResults when running from dotnet test on Windows #5292

@CheezeCS

Description

@CheezeCS

Describe the bug

Hello, when running tests on Windows with dotnet test when using the ‘retry’ parameter, the test run terminates with an error, due to moving a file that is used by another process

Steps To Reproduce

  1. Create simple unit test
  2. Run it through dotnet test -- --retry-failed-tests 1 on Windows
  3. error run failed: Tests failed

Expected behavior

Test run completes without errors

Actual behavior

Test run failed

Additional context

TestResults:

=====================
Tests suite completed successfully in 1 attempts
=====================

=====================
Moving last attempt asset files to the default result directory
=====================

Moving file 'C:\RiderProjects\Allure.Testing.Platform\TestProject1\bin\Debug\net8.0\TestResults\Retries\qNqn3\1\TestProject1_net8.0_x64.log' to 'C:\RiderProjects\Allure.Testing.Platform\TestProject1\bin\Debug\net8.0\TestResults\TestProject1_net8.0_x64.log'
Unhandled exception. System.IO.IOException: The process cannot access the file because it is being used by another process.
   at System.IO.FileSystem.MoveFile(String sourceFullPath, String destFullPath, Boolean overwrite)
   at Microsoft.Testing.Extensions.Policy.RetryOrchestrator.OrchestrateTestHostExecutionAsync() in /_/src/Microsoft.Testing.Extensions.Retry/RetryOrchestrator.cs:line 320
   at Microsoft.Testing.Platform.Hosts.TestHostOrchestratorHost.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Hosts/TestHostOchestratorHost.cs:line 30
   at Microsoft.Testing.Platform.Builder.TestApplication.RunAsync() in /_/src/Platform/Microsoft.Testing.Platform/Builder/TestApplication.cs:line 244
   at Xunit.Runner.InProc.SystemConsole.TestingPlatform.TestPlatformTestFramework.RunAsync(String[] args, Action`2 extensionRegistration) in /_/src/xunit.v3.runner.inproc.console/TestingPlatform/TestPlatformTestFramework.cs:line 270
   at XunitAutoGeneratedEntryPoint.Main(String[] args) in C:\.nuget\packages\xunit.v3.core\1.1.0\_content\EntryPoint-mtp.cs:line 11

=== COMMAND LINE ===
C:\Program Files\dotnet\dotnet.exe exec C:\RiderProjects\Allure.Testing.Platform\TestProject1\bin\Debug\net8.0\TestProject1.dll --internal-msbuild-node testingplatform.pipe.b37faf106d7441fd8df06ddea3148887 --retry-failed-tests 1 

Metadata

Metadata

Assignees

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions