You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes it is necessary to unit-test the code which relies on a static state or even worse, on the type initializers execution order. Even after fixing this kind of nonsense, the problem doesn't entirely go away, because now you need to test it against different scenarios to avoid false positives.
My solution is intended to solve this problem for .NET Core users, who doesn't have full AppDomain functionality.
It relies on AssemblyLoadContext and IFixtureBuilder extension point to achieve the result. I have basically copy-pasted TestFixtureAttribute code and changed BuildFrom methods to use the type from the newly created AssemblyLoadContext.
This approach have a few limitations:
It doesn't support isolation of test methods, only test classes.
This issue is marked as an idea/design but hasn't had contributions in years so I am closing. If anyone is interested in working on this idea, post your interest and the team will consider reopening.
Sometimes it is necessary to unit-test the code which relies on a static state or even worse, on the type initializers execution order. Even after fixing this kind of nonsense, the problem doesn't entirely go away, because now you need to test it against different scenarios to avoid false positives.
My solution is intended to solve this problem for
.NET Core
users, who doesn't have fullAppDomain
functionality.It relies on AssemblyLoadContext and IFixtureBuilder extension point to achieve the result. I have basically copy-pasted
TestFixtureAttribute
code and changedBuildFrom
methods to use the type from the newly createdAssemblyLoadContext
.This approach have a few limitations:
It doesn't support isolation of test methods, only test classes.
It doesn't support
AssemblyLoadContext
unload, because as of now, it is not supported by the run-time, but it is planned: https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/unloadability.mdThe design is poor. It can look better as a property of existing
TestFixtureAttribute
But in general it works, my tests are no longer sharing static variables!
So I request you to add this killer-feature to the NUnit, to make more users happier.
The text was updated successfully, but these errors were encountered: