The title says it - What happens between TestMethods in MS Visual Studio Unit Tests?
I have a bunch of TestMethods in a TestClass that has a TestInitialize method.
The TestInitialize method internally loads a Type via Reflection (eg. Type.GetType("MyContainer, MyContainerAssembly")
). MyContainer is a class that inherits from WindsorContainer (from Castle Windsor).
When I choose to run all unit tests in the solution, the first time TestInitialize is called (for the first TestMethod), this works all well and good. When the second TestMethod executes and TestInitialize is called, my Type.GetType call returns null.
I put a breakpoint inside the TestInitialize method and verified this. To debug the issue, I tried in the Immediate Window:
Assembly.Load("MyContainerAssembly")
which worked...then:
Assembly.Load("MyContainerAssembly").GetTypes()
and what do you know? It threw a TypeLoaderException saying that it couldn't find the assembly Castle.Windsor. Checked the bin\debug directory for the Unit Test project. It's there.
So then I tried: Assembly.Load("Castle.Windsor")
which worked...then:
Assembly.Load("Castle.Windsor").GetAssemblies()
...could not load Castle.Core...so then
Assembly.Load("Castle.Core")
then
Type.GetType("MyContainer, MyContainerAssembly")
again...and it returned the Type instance, not null.
Thoughts?