NUnit.Engine.NUnitEngineException when spaces in agent file path

See original GitHub issue

I ran this (sanitised) command using the console runner (version 3.15.2, installed via the NUnit.ConsoleRunner NuGet package): "T:\NUnit Console\tools\nunit3-console.exe" "Build Folder\MyTests.dll"

It failed with the following exception:

Unhandled Exception: NUnit.Engine.NUnitEngineException: Remote test agent exited with non-zero exit code -2147450735
   at NUnit.Engine.Services.TestAgency.OnAgentExit(Process process, Guid agentId)
   at NUnit.Engine.Services.TestAgency.<>c__DisplayClass13_0.<GetAgent>b__0(Object sender, EventArgs e)
   at System.Diagnostics.Process.OnExited()
   at System.Diagnostics.Process.RaiseOnExited()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(Object state, Boolean timedOut)

Errors, Failures and Warnings

1) Error :
NUnit.Engine.NUnitEngineException : Unable to acquire remote process agent
--NUnitEngineException
Unable to acquire remote process agent
   at NUnit.Engine.Runners.ProcessRunner.CreateAgentAndRunnerIfNeeded()
   at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)

I enabled debug logging and found the following line:

22:31:32.929 Debug [ 1] TestAgency: Command line: "C:\Program Files (x86)\dotnet\dotnet.exe" T:\NUnit Console\tools\agents\net6.0\nunit-agent.dll 9c396990-3a76-47bf-a018-a480508cf7de 127.0.0.1:50621 --pid=9968 --trace=Verbose --work="E:\My Folder"

The non-quoted file path to nunit-agent.dll was suspicious! When I changed the NUnit console package file path to just T:\NUnitConsole (i.e. without the space) everything worked fine.

The rename will work fine for us for now, but I feel like this is a bug that should be fixed? Having found the line of code in AgentProcess.cs it is definitely expected to be a full file path that is passed to dotnet.exe, and therefore it should be quoted? I think it should be reproducible for any .NET 6 test assembly simply by running the NUnit Console package from a path with spaces in.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
cw397commented, Aug 17, 2022

@CharliePoole sorry for taking so long, but I can confirm that 3.15.3-dev00002 does indeed fix the issue we were seeing.

0reactions
CharliePoolecommented, Nov 15, 2022

This issue has been resolved in version 3.16.0

The release is available on: GitHub. NuGet packages are also available NuGet.org and Chocolatey Packages may be found at Chocolatey.org

Read more comments on GitHub >

github_iconTop Results From Across the Web

Space characters in the work directory path are not ...
The problem is in the "nunit-console-3.9\src\NUnitEngine\nunit.engine\Services\TestAgency.cs" source file inside LaunchAgentProcess method.
Read more >
I am trying to run a test using NUnitEngine. But, it gives me ...
The .NET Core build of the NUnit Engine currently only works when it is located in the same directory as the tests. As...
Read more >
Console and Engine Release Notes
Engine.NUnitEngineException when spaces in agent file path; #1208 Inconsistencies between nunit3-console and running the project via Visual Studio ...
Read more >
[mapguide-commits] r9127 - in trunk/Tools/Maestro: Maestro/.nuget ...
Warn are now displayed + +Engine + + * NUnit agents now monitor the running ... Engine Tests fail if not run from...
Read more >
Encountering System.IO.PathTooLongException from Nunit ...
I am encountering System.IO.PathTooLongException from the Nunit 3.0.1 console runner (installed via Nuget) and am looking for some ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found