TL;DR Is there an equivalent dotnet test
switch to NUnit's --inprocess
?
Because running dotnet
test
as StartProgram
with the normal VS Debuigging experience (F5) does not allow to debug the test.
Our tests are written in NUnit 3. We are currently migrating our project from .NET Framework 4.8 to .NET 6.
Since running tests via nunit3-console.exe
does not always work (e.g. https://github.com/nunit/nunit-console/issues/1253) we are also migrating the runner to dotnet test
which currently works more seamlessly for us.
However, our devs used to be free to debug their tests how they wanted. Some used the VS Test Explorer, others used the normal VS debugger and "F5" with startup settings approx. nunit3-console.exe --inprocess some.test.dll
.
The problem now is that I cannot find any way to debug an NUnit test started with <StartProgram>dotnet test
from within the VS GUI.
I found: How to debug dotnet test in VS Code? which suggests setting VSTEST_HOST_DEBUG=1
, but (a) you cannot set env vars with csproj StartProgram
and (b) it doesn't seem to work with NUnit anyway.
I want to:
I could do this with nunit-console.exe --inprocess
-- is this possible with dotnet test
at all?
Allegedly, this is not possible with dotnet test
:
Unfortunately, even if
dotnet test
runs in-process, it will spawn atesthost.exe
to run your tests. SettingVSTEST_HOST_DEBUG
simply tellstesthost.exe
to wait for a debugger to be manually connected. - NPras
So the situation is similar to what NUnit (console runner) offers/offered with the --debug
switch.