google-code-export / mb-unit

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

Visual Studio 2008 (Mono.Cecil) failing to render MbUnit3 tests that are decorated with ExpectedException attribute. #697

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Update a Visual Studiio project file to integrate MBUnit3 into the VS2008 
IDE.
2. Decorate a test with the [ExpectedException] attribute.
3. When Visual Studio renders the tests, notice that the test disappears from 
the Visual Studio 'Test View' window.
4. Notice the '[error] An exception was thrown while exploring tests.' text 
that has been written to the 'Test > Output' window.

What is the expected output? What do you see instead?

I think that tests decorated with the ExpectedException attribute should be 
displayed in the Visual Studio 'Test View' window.

What version of the product are you using? On what operating system?

I am using Gallio bundle 3.1.397.

Please provide any additional information below.

I've updated my Visual Studio project file to include ProjectTypeGuids that 
integrate my MbUnit v3 tests into the Visual Studio 2008 IDE.

<PropertyGroup>
    <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>

This works great, however when I decorate a Test with an [ExpectedException] 
attribute, Visual Studio appears to have some problems rendering the tests:

[error] An exception was thrown while exploring tests.
       Location: D:\<MyDir>\MyClass.cs(238)
       Details: System.FormatException: Input string was not in a correct
format.
  at System.Number.StringToNumber(String str, NumberStyles options,
NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
  at System.Number.ParseInt32(String s, NumberStyles style,
NumberFormatInfo info)
  at System.Byte.Parse(String s, NumberStyles style, NumberFormatInfo
info)
  at Mono.Cecil.AssemblyNameReference.Parse(String fullName)
  at Mono.Cecil.Signatures.SignatureReader.CreateTypeReference(String
typeName, String asmName, Boolean isValueType)
  at Mono.Cecil.Signatures.SignatureReader.CreateTypeReference(String
typeName, Boolean isValueType)
  at Mono.Cecil.Signatures.SignatureReader.ReadSimpleValue(Byte[]
data, BinaryReader br, TypeReference type, Boolean& read, Boolean
resolve)
  at Mono.Cecil.Signatures.SignatureReader.ReadElem(Byte[] data,
BinaryReader br, TypeReference elemType, Boolean& read, Boolean
resolve)
  at
Mono.Cecil.Signatures.SignatureReader.ReadCustomAttrib(BinaryReader
br, Byte[] data, MethodReference ctor, Boolean resolve)
  at Mono.Cecil.Signatures.SignatureReader.GetCustomAttrib(Byte[]
data, MethodReference ctor, Boolean resolve)
  at Mono.Cecil.ReflectionReader.GetCustomAttribute(MethodReference
ctor, Byte[] data, Boolean resolve)
  at Mono.Cecil.CustomAttribute.Resolve()
  at
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.<EnumerateAttributes>d__31.M
oveNext()
in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common
\Reflection\Impl\CecilReflectionPolicy.cs:line 286
  at
Gallio.Common.Reflection.Impl.StaticCodeElementWrapper.<GetAllCustomAttributes>b
__13()
in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common
\Reflection\Impl\StaticCodeElementWrapper.cs:line 259
  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.StaticCodeElementWrapper.GetAllCustomAttributes()
in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common
\Reflection\Impl\StaticCodeElementWrapper.cs:line 255
  at
Gallio.Common.Reflection.Impl.StaticCodeElementWrapper.<GetAttributeInfos>d__1.M
oveNext()
in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common
\Reflection\Impl\StaticCodeElementWrapper.cs:line 55
  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.<GetAttributes>d__0`1.MoveNext()
in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Common
\Reflection\AttributeUtils.cs:line 50
  at
Gallio.Framework.Pattern.DeclarativePatternResolver.<GetPatterns>d__0.MoveNext()
in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio\Framework
\Pattern\DeclarativePatternResolver.cs:line 43
  at
Gallio.Framework.Pattern.DefaultPatternEvaluator.GetPrimaryPattern(ICodeElementI
nfo
codeElement) in c:\RelEng\Projects\MbUnit v3.1\Work\src\Gallio\Gallio
\Framework\Pattern\DefaultPatternEvaluator.cs:line 203
  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
147

For info, my ExpectedException attributes look like this, and they are being 
successfully rendered through the Gallio front-end.

       [Test]
       [ExpectedException(typeof(FaultException<SystemFault>), "Expected Exception message here...")]
       public void MyTest()
       {
       }

       [Test]
       [Row(null, null, ExpectedException = typeof(FaultException<SystemFault>), ExpectedExceptionMessage = "Expected Exception message here...")]
       public void MyTest2(int[] x, int[] y)
       {
       }

Please let me know if you need any more information.

Original issue reported on code.google.com by kevinbur...@gmail.com on 30 Jul 2010 at 8:56

GoogleCodeExporter commented 9 years ago
To upgrade Mono.Cecil binaries from v0.6 to latest.

Original comment by Yann.Tre...@gmail.com on 12 Aug 2010 at 5:58

GoogleCodeExporter commented 9 years ago
Graham made it :)

See build v3.3.121 and later.
Will be merged to v3.2 branch.

Original comment by Yann.Tre...@gmail.com on 24 Nov 2010 at 3:09

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 28 Nov 2010 at 2:05

GoogleCodeExporter commented 9 years ago

Original comment by Yann.Tre...@gmail.com on 5 Dec 2010 at 11:33

GoogleCodeExporter commented 9 years ago
For ref. 
http://stackoverflow.com/questions/5028333/gallio-error-an-exception-was-thrown-
while-exploring-tests/5029085#5029085

Original comment by Yann.Tre...@gmail.com on 17 Feb 2011 at 12:47