Wednesday, May 27, 2009

An exception was thrown while exploring tests. Gallio.

I was getting the below exception constantly while trying to run some unit tests in our solution.
[error] An exception was thrown while exploring tests.
Location: C:\x\Solutions\x.Web.Controllers\bin\Debug\x.Web.Controllers.DLL
Reference: x.Web.Controllers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at Gallio.Reflection.Impl.NativeAssemblyWrapper.GetTypes() in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Reflection\Impl\NativeAssemblyWrapper.cs:line 72
at Gallio.Framework.Pattern.TestAssemblyPatternAttribute.PopulateChildrenImmediately(PatternEvaluationScope assemblyScope, IAssemblyInfo assembly) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\TestAssemblyPatternAttribute.cs:line 122
at Gallio.Framework.Pattern.TestAssemblyPatternAttribute.Consume(PatternEvaluationScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\TestAssemblyPatternAttribute.cs:line 70
at Gallio.Framework.Pattern.PatternEvaluator.Consume(PatternEvaluationScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren, IPattern defaultPrimaryPattern) in c:\RelEng\Projects\MbUnit v3\Work\src\Gallio\Gallio\Framework\Pattern\PatternEvaluator.cs:line 196

Our tests rely on the gallio unit testing framework, which is pretty cool but thats for another post. This exception was driving me mad, until I noticed our solution had a bunch of referenced assemblies with CopyLocal set to False. This is great for build performance, but gallio didn't seem to like it.

Since referenced assemblies don't usually change much its nice to have copy local set to false, I didn't plan on changing this for gallio.

Writing a script to one-off copy the referenced assemblies into the unit test projects is the solution in this regard. Just a heads up incase you get caught in this trap.

Edit: Here a nice post about the subjects from one of my workmates. [+]

No comments:

Post a Comment