nunit-console
nunit-console copied to clipboard
ITestRunner.Run() does not pass Activity.Current to underlying test
We're calling specific tests programmatically through ITestRunner.Run(). In older versions of NUnit.Engine, the Activity.Current that was started before the Run() call was available in the test, and we use this to pass some data (a TraceId, to be specific).
In the current version, Activity.Current is set to null inside the test, which breaks our implementations.
Please see the attached zip file for a small C# project demonstrating the current, unexpected, behavior: ActivityDebugging.zip
Replacing the packages with these older versions shows the Activity.Current set as expected:
<PackageReference Include="NUnit.Engine" Version="3.15.2" />
<PackageReference Include="NUnit.Engine.Api" Version="3.15.2" />
<PackageReference Include="NUnit" Version="3.13.3" />
What happens if you use the 3.19 engine and api but vary the version of NUnit?
<PackageReference Include="NUnit.Engine" Version="3.19.0" />
<PackageReference Include="NUnit.Engine.Api" Version="3.19.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
results in a null Activity.Current, just like
<PackageReference Include="NUnit.Engine" Version="3.19.0" />
<PackageReference Include="NUnit.Engine.Api" Version="3.19.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
Just recording a few notes:
Change BOTH NUnit.Engine package versions to 3.18.3 (the release prior to 3.19.0) causes it to work properly.
<PackageReference Include="NUnit.Engine" Version="3.18.3" />
<PackageReference Include="NUnit.Engine.Api" Version="3.18.3" />
Changing EITHER package to 3.19.0 causes it to break.
There are not that many changes between https://github.com/nunit/nunit-console/compare/3.18.3...3.19.0 and there's nothing that sticks out obviously. This is removing support for a few things and changing the version of cake.tool from 4.0 to 5.0 so maybe there's a subtle difference in the versions that are loaded? Next step is to build a local copy of this with some additional logging because nothing stands out yet.
@veleek Have you tried a git bisect to narrow it down?
Nope but that was my next plan. I’m a little worried that it has something to do with the SDK that it was built with so I wanted to verify everything with released binaries first.
On Sun, Mar 2, 2025 at 05:43 CharliePoole @.***> wrote:
@veleek https://github.com/veleek Have you tried a git bisect to narrow it down?
— Reply to this email directly, view it on GitHub https://github.com/nunit/nunit-console/issues/1591#issuecomment-2692740196, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIBSLJ7HOPAT6T4SX7RD7L2SMDI3AVCNFSM6AAAAABUR2O2YKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSG42DAMJZGY . You are receiving this because you were mentioned.Message ID: @.***> [image: CharliePoole]CharliePoole left a comment (nunit/nunit-console#1591) https://github.com/nunit/nunit-console/issues/1591#issuecomment-2692740196
@veleek https://github.com/veleek Have you tried a git bisect to narrow it down?
— Reply to this email directly, view it on GitHub https://github.com/nunit/nunit-console/issues/1591#issuecomment-2692740196, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIBSLJ7HOPAT6T4SX7RD7L2SMDI3AVCNFSM6AAAAABUR2O2YKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMOJSG42DAMJZGY . You are receiving this because you were mentioned.Message ID: @.***>
After FAR too much work into this I've determined that there's a difference between netcoreapp2.1 (and earlier, like netstandard2.0) and net6.0 and greater.
There were a lot of project/framework/versioning changes around when I was working so I basically needed to nuke and rebuild everything each step and update Assembly Reference paths because a bunch of assembly build path changes happened around the same time period I was investigating.
I've validated this as far back as 3.17.0 which produced both a netcoreapp3.1 binary (which fails) AND netcoreapp2.1 binary (which succeeds).