MudassarRasool / mb-unit

Automatically exported from code.google.com/p/mb-unit
0 stars 0 forks source link

System.NullReferenceException when running NUnit tests #653

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  Open a solution containing NUnit tests
2.  Hit Ctrl+R, A to run all the unit tests in the solution
3.  View Test Output and note the NullReferenceException

What is the expected output? What do you see instead?
Expected output/action is for tests to run correctly, as happens in the 
standalone Gallio Test runner, TestDriven.NET and NUnit GUI.  Actual output 
is a System.NullReferenceException in Gallio:

[error] An exception was thrown while finishing the population of the NUnit 
test model.
    Details: System.NullReferenceException: Object reference not set to 
an instance of an object.
   at 
Mono.Cecil.ReflectionReader.VisitExternTypeCollection(ExternTypeCollection 
externs)
   at Mono.Cecil.AggressiveReflectionReader.ReadExternTypes()
   at 
Mono.Cecil.AggressiveReflectionReader.VisitTypeDefinitionCollection(TypeDef
initionCollection types)
   at Mono.Cecil.ReflectionReader.VisitModuleDefinition(ModuleDefinition 
mod)
   at 
Mono.Cecil.StructureReader.TerminateAssemblyDefinition(AssemblyDefinition 
asm)
   at Mono.Cecil.AssemblyDefinition.Accept(IReflectionStructureVisitor 
visitor)
   at Mono.Cecil.AssemblyFactory.GetAssembly(ImageReader irv, Boolean 
manifestOnly)
   at Mono.Cecil.AssemblyFactory.GetAssembly(String file)
   at 
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.CustomAssemblyResolver.
LoadAssembly(String assemblyFile) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs
:line 833
   at 
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.CustomAssemblyResolver.
Resolve(AssemblyNameReference name) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs
:line 867
   at 
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.<>c__DisplayClass72.<Ma
keType>b__71() in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs
:line 701
   at Gallio.Common.KeyedMemoizer`2.Memoize(TKey key, Func`1 populator) in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\KeyedMemoizer.cs:line 91
   at 
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.MakeType(TypeReference 
typeHandle) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs
:line 672
   at 
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.WrapConstructor(MethodR
eference methodRefHandle) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs
:line 73
   at 
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.GetAttributeConstructor
(StaticAttributeWrapper attribute) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs
:line 245
   at 
Gallio.Common.Reflection.Impl.StaticAttributeWrapper.<get_Constructor>b__0(
) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticAttributeWrapper.c
s:line 57
   at Gallio.Common.Memoizer`1.Memoize(Func`1 populator) in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Memoizer.cs:line 67
   at 
Gallio.Common.Reflection.Impl.StaticAttributeWrapper.get_Constructor() in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticAttributeWrapper.c
s:line 57
   at Gallio.Common.Reflection.Impl.StaticAttributeWrapper.get_Type() in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticAttributeWrapper.c
s:line 49
   at 
Gallio.Common.Reflection.Impl.StaticCodeElementWrapper.<GetAttributeInfos>d
__1.MoveNext() in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticCodeElementWrapper
.cs:line 63
   at 
Gallio.Common.Reflection.AttributeUtils.<ResolveAttributes>d__c.MoveNext() 
in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\AttributeUtils.cs:line 127
   at Gallio.Common.Reflection.AttributeUtils.GetAttribute(ICodeElementInfo 
element, Type attributeType, Boolean inherit) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\AttributeUtils.cs:line 78
   at 
Gallio.Common.Reflection.AttributeUtils.GetAttribute[T](ICodeElementInfo 
element, Boolean inherit) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\AttributeUtils.cs:line 38
   at Gallio.Model.ModelUtils.PopulateMetadataFromAssembly(IAssemblyInfo 
assembly, PropertyBag metadataMap) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Model\ModelUtils.cs:line 55
   at 
Gallio.NUnitAdapter.Model.NUnitTestExplorerEngine.PopulateAssemblyTestMetad
ata(Test assemblyTest, IAssemblyInfo assembly)
   at Gallio.NUnitAdapter.Model.NUnitReflectiveTestExplorerEngine.Finish()
   at Gallio.NUnitAdapter.Model.NUnitTestExplorer.Finish()

What version of the product are you using? On what operating system?
Gallio 3.1.397 x64; VS2010 Ultimate; Windows 7 Ultimate x64

Original issue reported on code.google.com by alastair...@gmail.com on 22 Apr 2010 at 8:25

GoogleCodeExporter commented 8 years ago
FWIW, I also have UAC enabled to the default Windows 7 setting (Notify me only 
when 
programs try to make changes to my computer).  My user account is a domain 
account, 
with local administrator privileges.  

Original comment by alastair...@gmail.com on 22 Apr 2010 at 8:28

GoogleCodeExporter commented 8 years ago
Could you please provide a sample that causes the error?

Original comment by grahamr...@gmail.com on 4 May 2010 at 8:31

GoogleCodeExporter commented 8 years ago
I'd prefer not to send the problematic solution itself as it's not open-source 
code.  I tried to put together 
a sample project to demonstrate it, but failed to do so: the tests wouldn't run 
in Visual Studio and a 
message appears in the VS status bar explaining that "No tests were run because 
no tests are loaded or the 
selected tests are disabled".  I did a spot of digging, and for some reason, 
the Gallio plug-in "Visual 
Studio Integration Shell" isn't loading properly, and other plugins dependent 
on it then also fail.  Here's 
Gallio's reason for disabling this plugin:

> The plugin enable condition was not satisfied: '${process:DEVENV.EXE} or 
${process:VSTESTHOST.EXE} or 
${process:QTAGENT.EXE} or ${process:QTAGENT32.EXE} or ${process:QTDCAGENT.EXE} 
or ${process:QTDCAGENT32.EXE}

As an aside, would it be possible for the box on the Gallio Control Panel that 
displays that information to 
support copying its contents? Typing it out is a bit of a drag...

In the problematic solution I can invoke a test run attempt using Ctrl+R,T but 
I get the exception thrown 
above and the same status bar message.  The Gallio Control Panel reports the 
same problem with the plug-ins.  
Subsequent attempts to invoke a test run fail with the same status bar message; 
if I do a build and then 
attempt another test run, the exception and status bar messages are displayed 
again.  

I've tried reinstalling Gallio a couple of times, made no difference.

Does that help at all?  Sorry to be cagey with the sample.

Original comment by alastair...@gmail.com on 4 May 2010 at 10:47

GoogleCodeExporter commented 8 years ago
Not sure this is directly related, but a very similar issue occurs with MBUnit 
tests launched from our MSBuild process. We're running Gallio version 3.1 as 
shown in log messages below. After encountering this error, we usually just 
restart the build process from Team City and the error disappears....

[07:51:41]: Test:
[07:51:41]:   Gallio MSBuild Task - Version 3.1 build 397
[07:51:41]:   Start time: 7:51 AM
[07:51:41]:   
[07:51:41]: Initializing test runner.' flowId='f8d7b7d29601fe3f
[07:51:41]:   
[07:51:41]: Running tests.' flowId='f8d7b7d29601fe3f
[07:51:40]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Solution compatibility: SharePoint 2007 and SharePoint 2010
[07:51:40]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Saving the Manifest.xml file
[07:51:40]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Creating the WSP file
[07:51:41]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Cleanup
[07:51:41]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Done!
[07:51:41]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Gallio MSBuild Task - Version 3.1 build 397
[07:51:41]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Start time: 7:51 AM
[07:51:41]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Initializing test runner.' flowId='f8d7b7d29601fe3f
[07:51:41]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Running tests.' flowId='f8d7b7d29601fe3f
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error : An exception was thrown while exploring tests. 
[C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error : Reference: EDIS.Test, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=04f11aef856b7bba 
[C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error : Details: System.Reflection.ReflectionTypeLoadException: Unable to load 
one or more of the requested types. Retrieve the LoaderExceptions property for 
more information. 
[C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) 
[C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at System.Reflection.RuntimeModule.GetTypes() 
[C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at System.Reflection.Assembly.GetTypes() 
[C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at Gallio.Common.Reflection.Impl.NativeAssemblyWrapper.GetTypes() in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\NativeAssemblyWrapper.cs:line
 72 [C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at 
Gallio.Framework.Pattern.TestAssemblyPatternAttribute.PopulateChildrenImmediatel
y(IPatternScope assemblyScope, IAssemblyInfo assembly) in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Framework\Pattern\TestAssemblyPatternAttribute.cs:li
ne 147 [C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at 
Gallio.Framework.Pattern.TestAssemblyPatternAttribute.Consume(IPatternScope 
containingScope, ICodeElementInfo codeElement, Boolean skipChildren) in 
c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Framework\Pattern\TestAssemblyPatternAttribute.cs:li
ne 73 [C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:44]: C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL : 
error :    at 
Gallio.Framework.Pattern.DefaultPatternEvaluator.Consume(IPatternScope 
containingScope, ICodeElementInfo codeElement, Boolean skipChildren, IPattern 
defaultPrimaryPattern) in c:\RelEng\Projects\MbUnit 
v3.1\Work\src\Gallio\Gallio\Framework\Pattern\DefaultPatternEvaluator.cs:line 
153 [C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild.teamcity.patch.tcprojx]
[07:51:45]:   
[07:51:45]: EDIS.Test
[07:51:45]:   
[07:51:44]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] C:\_Projects3_5\SPS\EDIS\trunk\EDIS.Test\bin\Debug\EDIS.Test.DLL 
An exception was thrown while exploring tests.
Reference: EDIS.Test, Version=1.0.0.0, Culture=neutral, 
PublicKeyToken=04f11aef856b7bba
Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or 
more of the requested types. Retrieve the LoaderExceptions property for more 
information.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at Gallio.Common.Reflection.Impl.NativeAssemblyWrapper.GetTypes() in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common\Reflection\Impl\NativeAssemblyWrapper.cs:line 72
   at Gallio.Framework.Pattern.TestAssemblyPatternAttribute.PopulateChildrenImmediately(IPatternScope assemblyScope, IAssemblyInfo assembly) in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework\Pattern\TestAssemblyPatternAttribute.cs:line 147
   at Gallio.Framework.Pattern.TestAssemblyPatternAttribute.Consume(IPatternScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren) in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework\Pattern\TestAssemblyPatternAttribute.cs:line 73
   at Gallio.Framework.Pattern.DefaultPatternEvaluator.Consume(IPatternScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren, IPattern defaultPrimaryPattern) in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework\Pattern\DefaultPatternEvaluator.cs:line 153
[07:51:45]: EDIS.Test
[07:51:45]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Disposed test runner.' flowId='f8d7b7d29601fe3f
[07:51:45]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] Stop time: 7:51 AM (Total execution time: 3.852 seconds)
[07:51:45]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild(20, 5): 0 run, 0 
passed, 0 failed, 0 inconclusive, 0 skipped
[07:51:45]: [Project "EDIS.msbuild.teamcity.patch.tcprojx" (ServerConfig;Test 
target(s)):] C:\_Projects3_5\SPS\EDIS\trunk\EDIS.msbuild(24, 5): Tests 
execution failed
[07:51:45]:   
[07:51:45]:   
[07:51:45]: Disposed test runner.' flowId='f8d7b7d29601fe3f
[07:51:45]:   Stop time: 7:51 AM (Total execution time: 3.852 seconds)

Original comment by brownli...@gmail.com on 15 Mar 2011 at 2:11