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
{{ message }}
Repository navigation
3.11.0 fails on vstest.console.exe but works in visual studio 2022/insider #6676
After updating the nuget packages to 3.11.0 tests seem to run in different appdomains/contexts but only when using vstest.console.exe.
If running the tests in visual studio everything is fine.
Symptoms:
Tests with shared variables are crashing (after further analysis the actual issue seems to be also related to type resolving in a different context/appdomain)
Tests that load types via reflection fail e.g. TypeA is different from TypeA (apparently loaded in another context)
With 3.9.3 everything works as expected.
Looking at the fusion logs I can see warnings like this, for the assembly where the tests are located in:
WRN: The same assembly was loaded into multiple contexts of an application domain:...
Again, switching to 3.9.3 these warnings are gone and the binder log entry looks exactly the same (excluding the warnings at the end)
I tried to reproduce it with a simple solution but there everything works so I assume there is something wrong with project/solution but since it all works in 3.9.3 I wonder what the difference might be between those 2 versions and what would cause the newer version to behave differently.
Can you share the project, runsettings and other "generic" parts of the project that are not showing any company secrets?
Unfortunately I am not able to share the project.
No runsettings used.
I can maybe go into detail what exactly is failing:
Setting a shared/static variable on TestInitialize, is null when accessing it inside a test method of that test class
Activator.CreateInstance(Type.GetType("Assembly.Of.TypeA.TypeA, Assembly.Of.TypeA")) returns an instance of TypeA but when asserting the expected type "TypeA" it fails because TypeA is different from TypeA (I assume it's loaded in another context from what I can see in the logs e.g. warnings and multiple appdomain ids)
The statement about the static/shared variables was wrong/a misinterpretation of the error message I am seeing, in reality it seems to be another issue with type resolving, my bad.
thanks, that sounds like 2 symptoms of the same problem. I am trying to repro, but I don't see it reproduce. Nor can I think about situation where this would happen. Because we don't isolate tests within class into separate appdomains.
What is different when running in vstest.console and in visual studio, is that vstest.console allows shared mode for dlls, which will allow multiple test assemblies to be loaded into the same process and run isolated in their own appdomains.
I'd try to add /inisolation to your commandline run, to see if you will see different result. In VS you always run inIsolation.
I'd try to add /inisolation to your commandline run, to see if you will see different result. In VS you always run inIsolation.
This is still true, that should have you in good state in both VS and commandline. If it does, then we need to see if the warning really is not there before as well. and if we are getting the same behavior.
Activity
nohwnd commentedon Oct 6, 2025
Is this as opposed to running with MTP?
Can you share the project, runsettings and other "generic" parts of the project that are not showing any company secrets?
nohwnd commentedon Oct 6, 2025
I cannot read, sorry.
Epicycle23 commentedon Oct 6, 2025
Unfortunately I am not able to share the project.
No runsettings used.
I can maybe go into detail what exactly is failing:
Epicycle23 commentedon Oct 6, 2025
The statement about the static/shared variables was wrong/a misinterpretation of the error message I am seeing, in reality it seems to be another issue with type resolving, my bad.
nohwnd commentedon Oct 6, 2025
thanks, that sounds like 2 symptoms of the same problem. I am trying to repro, but I don't see it reproduce. Nor can I think about situation where this would happen. Because we don't isolate tests within class into separate appdomains.
What is different when running in vstest.console and in visual studio, is that vstest.console allows shared mode for dlls, which will allow multiple test assemblies to be loaded into the same process and run isolated in their own appdomains.
I'd try to add /inisolation to your commandline run, to see if you will see different result. In VS you always run inIsolation.
nohwnd commentedon Oct 6, 2025
in light of the last comment:
I'd try to add /inisolation to your commandline run, to see if you will see different result. In VS you always run inIsolation.
This is still true, that should have you in good state in both VS and commandline. If it does, then we need to see if the warning really is not there before as well. and if we are getting the same behavior.
Epicycle23 commentedon Oct 6, 2025
I already tried to run it with /inisolation but it didn't make a difference.
Epicycle23 commentedon Oct 6, 2025
More detail about what's happening with 3.11.0:
Assemblies are loaded from 2 different locations:
Still completely confused why that only happens with 3.11.0 but not with 3.9.3
nohwnd commentedon Oct 6, 2025
Do you use the deploy attribute on some of the tests? Maybe that is what is missing in my wannabe repro.
Epicycle23 commentedon Oct 6, 2025
Yes, the DeploymentItem attribute is used on some tests.
nohwnd commentedon Oct 10, 2025
Please follow up in #6713 we think that is caused by the same problem in MSTest code.