Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ITestRunner.Run() does not pass Activity.Current to underlying test #1591

Open
DanielVuurboom opened this issue Jan 3, 2025 · 8 comments
Open
Assignees
Labels
3.20? Under consideration for inclusion in 3.20 release Bug Investigate We are looking into the issue
Milestone

Comments

@DanielVuurboom
Copy link

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" />
@CharliePoole
Copy link
Member

What happens if you use the 3.19 engine and api but vary the version of NUnit?

@DanielVuurboom
Copy link
Author

DanielVuurboom commented Jan 6, 2025

    <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" />

@veleek veleek self-assigned this Jan 26, 2025
@veleek veleek added Bug Investigate We are looking into the issue labels Jan 26, 2025
@veleek veleek added this to the 3.20.0 milestone Jan 26, 2025
@veleek
Copy link
Member

veleek commented Mar 2, 2025

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.

@veleek
Copy link
Member

veleek commented Mar 2, 2025

There are not that many changes between 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.

@CharliePoole
Copy link
Member

@veleek Have you tried a git bisect to narrow it down?

@veleek
Copy link
Member

veleek commented Mar 2, 2025 via email

@veleek
Copy link
Member

veleek commented Mar 5, 2025

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.

@veleek
Copy link
Member

veleek commented Mar 5, 2025

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).

@CharliePoole CharliePoole added the 3.20? Under consideration for inclusion in 3.20 release label Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.20? Under consideration for inclusion in 3.20 release Bug Investigate We are looking into the issue
Projects
None yet
Development

No branches or pull requests

3 participants