gdosreis / mb-unit

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

Exception from Row test with Enum parameter #858

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a rowtest that takes an enum value as its param. This enum should be 
defined in a different module to the module being tested, but still referenced 
in the test project (it may not need to be a separate module but this is the 
scenario in which it has manifested for me).
2. Compile your project in VS2010.
3. Run a unit test.
4. Rebuild project again.

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

I see the stack trace below in the tests output window. I expect not to see 
that stack trace and can stop it occurring by commenting out the rowtest. n.b. 
this only seems to happen after a unit test has been run once. If one opens a 
fresh instance of visual studio loads the project and hit rebuild, it is ok 
until a test is subsequently run.

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

win7 64
Gallio 3.2 750

Please provide any additional information below.

Every time I build my project I now get this
error in the tests output panel.

I've worked out what the cause is. I have some Row() tests that take
an enum defined in one of my modules (TestProj.Domain) as their
parameters. As soon as I comment these out the problem goes so it
looks like an issue resolving the module defining these.

e.g. :

                [Test]
                [Row(MembershipStatus.Admin)]
                [Row(MembershipStatus.Banned)]
                [Row(MembershipStatus.Invited)]
                [Row(MembershipStatus.Member)]
                [Row(MembershipStatus.NotMember)]
                public void Can_Add_And_Get_Member_With_Status(MembershipStatus
status)
                {
.....

causes the error. The references are all fine though and the code
compiles + passes the tests so the problem seems localised to gallios
reflection pass.

[error] An exception was thrown while exploring tests.
        Location: C:\Repos\SvnHome\Windows\TestProjNet
\TestProjNet.Domain.Repositories.MongoDb.Test\MembershipList
\When_Creating_MembershipList.cs(90)
        Details: System.IO.FileNotFoundException: Could not resolve:
TestProjNet.Domain, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference
name)
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference
name)
   at Mono.Cecil.MetadataResolver.Resolve(IAssemblyResolver resolver,
TypeReference type)
   at Mono.Cecil.TypeReference.Resolve()
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum(TypeReference
enum_type)
   at
Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue(TypeReference
type)
   at
Mono.Cecil.SignatureReader.ReadCustomAttributeElement(TypeReference
type)
   at
Mono.Cecil.SignatureReader.ReadCustomAttributeElement(TypeReference
type)
   at
Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArrayArgument(ArrayType
type)
   at
Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument(TypeReference
type)
   at
Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments(CustomAttribu
te
attribute, Collection`1 parameters)
   at
Mono.Cecil.MetadataReader.ReadCustomAttributeSignature(CustomAttribute
attribute)
   at Mono.Cecil.CustomAttribute.<Resolve>b__2(CustomAttribute
attribute, MetadataReader reader)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3
read)
   at Mono.Cecil.CustomAttribute.Resolve()
   at Mono.Cecil.CustomAttribute.get_ConstructorArguments()
   at
Gallio.Common.Reflection.Impl.CecilReflectionPolicy.GetAttributeConstructorArgum
ents(StaticAttributeWrapper
attribute) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio
\Common\Reflection\Impl\CecilReflectionPolicy.cs:line 248
   at
Gallio.Common.Reflection.Impl.StaticAttributeWrapper.get_InitializedArgumentValu
es()
in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Common
\Reflection\Impl\StaticAttributeWrapper.cs:line 98
   at
Gallio.Common.Reflection.Impl.ReflectorAttributeUtils.CreateAttribute(IAttribute
Info
attribute, Boolean throwOnError) in c:\Server\Projects\MbUnit v3.2\Work
\src\Gallio\Gallio\Common\Reflection\Impl
\ReflectorAttributeUtils.cs:line 54
   at
Gallio.Common.Reflection.Impl.StaticAttributeWrapper.<>c__DisplayClass10.<Resolv
e>b__f()
in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Common
\Reflection\Impl\StaticAttributeWrapper.cs:line 143
   at Gallio.Common.KeyedMemoizer`2.Memoize(TKey key, Func`1
populator) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio
\Common\KeyedMemoizer.cs:line 91
   at
Gallio.Common.Reflection.Impl.StaticAttributeWrapper.Resolve(Boolean
throwOnError) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio
\Common\Reflection\Impl\StaticAttributeWrapper.cs:line 142
   at
Gallio.Common.Reflection.AttributeUtils.<ResolveAttributes>d__c.MoveNext()
in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Common
\Reflection\AttributeUtils.cs:line 132
   at
Gallio.Common.Reflection.AttributeUtils.<GetAttributes>d__0`1.MoveNext()
in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Common
\Reflection\AttributeUtils.cs:line 50
   at
Gallio.Framework.Pattern.DeclarativePatternResolver.<GetPatterns>d__0.MoveNext()
in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio\Framework
\Pattern\DeclarativePatternResolver.cs:line 43
   at
Gallio.Framework.Pattern.DefaultPatternEvaluator.GetPrimaryPattern(ICodeElementI
nfo
codeElement) in c:\Server\Projects\MbUnit v3.2\Work\src\Gallio\Gallio
\Framework\Pattern\DefaultPatternEvaluator.cs:line 183
   at
Gallio.Framework.Pattern.DefaultPatternEvaluator.Consume(IPatternScope
containingScope, ICodeElementInfo codeElement, Boolean skipChildren,
IPattern defaultPrimaryPattern) in c:\Server\Projects\MbUnit v3.2\Work
\src\Gallio\Gallio\Framework\Pattern\DefaultPatternEvaluator.cs:line
127

Original issue reported on code.google.com by Daniel.A...@gmail.com on 14 Sep 2011 at 8:16

GoogleCodeExporter commented 9 years ago
Is that the R# plugin?

Original comment by grahamr...@gmail.com on 28 Sep 2011 at 7:57

GoogleCodeExporter commented 9 years ago
I'm experiencing this as well. I've added mbUnit & Gallio via NuGet (and have 
gallio 3.3.1)

In the below Territory.UkShortName is a public string and Policy.ModifierType 
is a public enum both in the module the test references.

This test compiles happily

[Test]
[Row("rock", Territory.UkShortName, 5.04, 3)]
public void ShouldGetCorrectModifiersWhenReadingFile(string policyName, 
                                                     string territoryName, 
                                                     decimal? expectedPrice, 
                                                     int modiferInt)
{
     var modifier = (Policy.ModifierType) modiferInt;
     Assert.AreEqual(expectedPrice,          
                     _factory.Policies[policyName]
                             .Territories[territoryName]
                             .GetModifierValue(modifier));
}

whereas 

[Test]
[Row("rock", Territory.UkShortName, 5.04, 
Policy.ModifierType.NineToTwentyWeeks)]
        public void ShouldGetCorrectModifiersWhenReadingFile(string policyName, 
                                                             string territoryName, 
                                                             decimal? expectedPrice, 
                                                             Policy.ModifierType modifier)
        {
            Assert.AreEqual(expectedPrice, 
                            _factory.Policies[policyName]
                                    .Territories[territoryName]
                                    .GetModifierValue(modifier));
        }

Outputs:

[error] An exception was thrown while exploring tests.
    Location: C:\Programming\ReadingPrices\ReadingPrices\ReadAlanFormatPrices.cs(66)
    Details: System.IO.FileNotFoundException: Could not resolve: RavenDal, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
   at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
   at Mono.Cecil.MetadataResolver.Resolve(IAssemblyResolver resolver, TypeReference type)
   at Mono.Cecil.TypeReference.Resolve()
   at Mono.Cecil.Mixin.CheckedResolve(TypeReference self)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeEnum(TypeReference enum_type)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeElementValue(TypeReference type)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeElement(TypeReference type)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeElement(TypeReference type)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArrayArgument(ArrayType type)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeFixedArgument(TypeReference type)
   at Mono.Cecil.SignatureReader.ReadCustomAttributeConstructorArguments(CustomAttribute attribute, Collection`1 parameters)
   at Mono.Cecil.MetadataReader.ReadCustomAttributeSignature(CustomAttribute attribute)
   at Mono.Cecil.CustomAttribute.<Resolve>b__2(CustomAttribute attribute, MetadataReader reader)
   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
   at Mono.Cecil.CustomAttribute.Resolve()
   at Mono.Cecil.CustomAttribute.get_ConstructorArguments()
   at Gallio.Common.Reflection.Impl.CecilReflectionPolicy.GetAttributeConstructorArguments(StaticAttributeWrapper attribute) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\Impl\CecilReflectionPolicy.cs:line 248
   at Gallio.Common.Reflection.Impl.StaticAttributeWrapper.get_InitializedArgumentValues() in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticAttributeWrapper.cs:line 98
   at Gallio.Common.Reflection.Impl.ReflectorAttributeUtils.CreateAttribute(IAttributeInfo attribute, Boolean throwOnError) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\Impl\ReflectorAttributeUtils.cs:line 54
   at Gallio.Common.Reflection.Impl.StaticAttributeWrapper.<>c__DisplayClass10.<Resolve>b__f() in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticAttributeWrapper.cs:line 143
   at Gallio.Common.KeyedMemoizer`2.Memoize(TKey key, Func`1 populator) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\KeyedMemoizer.cs:line 91
   at Gallio.Common.Reflection.Impl.StaticAttributeWrapper.Resolve(Boolean throwOnError) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\Impl\StaticAttributeWrapper.cs:line 142
   at Gallio.Common.Reflection.AttributeUtils.<ResolveAttributes>d__c.MoveNext() in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\AttributeUtils.cs:line 132
   at Gallio.Common.Reflection.AttributeUtils.<GetAttributes>d__0`1.MoveNext() in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Common\Reflection\AttributeUtils.cs:line 50
   at Gallio.Framework.Pattern.DeclarativePatternResolver.<GetPatterns>d__0.MoveNext() in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Framework\Pattern\DeclarativePatternResolver.cs:line 43
   at Gallio.Framework.Pattern.DefaultPatternEvaluator.GetPrimaryPattern(ICodeElementInfo codeElement) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Framework\Pattern\DefaultPatternEvaluator.cs:line 183
   at Gallio.Framework.Pattern.DefaultPatternEvaluator.Consume(IPatternScope containingScope, ICodeElementInfo codeElement, Boolean skipChildren, IPattern defaultPrimaryPattern) in c:\Server\Projects\MbUnit v3.3\Work\src\Gallio\Gallio\Framework\Pattern\DefaultPatternEvaluator.cs:line 127

Original comment by paul.dam...@gmail.com on 18 Apr 2012 at 2:38

GoogleCodeExporter commented 9 years ago
Oops - should add that the Row attribute allows enum parameters when they are 
in the same project but not when they are in another project in the solution.

Original comment by paul.dam...@gmail.com on 18 Apr 2012 at 6:49

GoogleCodeExporter commented 9 years ago
I can't reproduce this (see attached). What am I missing?

Original comment by grahamr...@gmail.com on 23 Apr 2012 at 6:00

Attachments:

GoogleCodeExporter commented 9 years ago
Ah, then this might be a project or machine setup thing. When I open your 
project in Visual Studio it doesn't see any tests to run.

I can reproduce by 
1) creating a class library and adding an enum
2) Adding a test project
3) removing the reference to MS unit testing
4) using nuget add mbunit to the test project
5) add a test using a local enum as a row attribute and it compiles & runs 
happily
6) add a test using the 'remote' enum as a row attribute.
7) Everything compiles but I see the output as above and the remote test isn't 
picked up as a test.

see attached.

Looking in my installed programs I've got Gallio 3.3 build 358 installed. I'll 
remove  that and see if anything changes.

Original comment by paul.dam...@gmail.com on 23 Apr 2012 at 6:49

Attachments:

GoogleCodeExporter commented 9 years ago
So having uninstalled Gallio from the machine your solution still shows no 
tests to run in (Test > Run > any option   i.e. Ctrl + R, A). My solution still 
shows that there are tests but when I try to run them I am told "no tests were 
run because no tests are loaded or the selected tests are disabled"

Original comment by paul.dam...@gmail.com on 23 Apr 2012 at 7:04

GoogleCodeExporter commented 9 years ago
I've also got Resharper installed and that sees no tests...

Original comment by paul.dam...@gmail.com on 23 Apr 2012 at 7:08

GoogleCodeExporter commented 9 years ago
JetBrains ReSharper 6.1 Full Edition
Build 6.1.37.86 on 2011-12-20T21:15:24

Licensed to: The BMC
Plugins: none
Visual Studio 10.0.40219.1.

Original comment by paul.dam...@gmail.com on 23 Apr 2012 at 7:13

GoogleCodeExporter commented 9 years ago
A fresh, complete install of Gallio 3.3 Build 458 lands me back in the same 
spot... this feels like I've got an unsupported setup...?

Original comment by paul.dam...@gmail.com on 23 Apr 2012 at 7:19

GoogleCodeExporter commented 9 years ago
I think R# 6.1 is only supported in the nightlies. We should really release 
that.

I can reproduce it with the sln you provided, but I suspect it's something to 
do with the VS add-in. 

I'm just downloading the latest 3.3 build now, I'll give it a try with that. 
What happens if you run the tests with Echo?

Original comment by grahamr...@gmail.com on 23 Apr 2012 at 7:54

GoogleCodeExporter commented 9 years ago
Yep, works fine and runs both tests with Echo: 

Gallio Echo - Version 3.3 build 454
Get the latest version at http://www.gallio.org/

Start time: 10:04
Initializing the runtime and loading plugins.
Verifying test files.
Initializing the test runner.
Running the tests.
[inconclusive] Test AddedTestProject/UnitTest1/TestLocally/TestLocally({One})
Execute
Gallio.Framework.TestInconclusiveException: this shouldn't throw an exception
   at AddedTestProject.UnitTest1.TestLocally(LocalEnum localEnum) in C:\Programm
ing\Issue858-paul\AddedTestProject\UnitTest1.cs:line 22

[inconclusive] Test AddedTestProject/UnitTest1/TestReferencedEnum/TestReferenced
Enum({One})
Execute
Gallio.Framework.TestInconclusiveException: this shouldn't throw an exception
   at AddedTestProject.UnitTest1.TestReferencedEnum(ReferencedEnum referencedEnu
m) in C:\Programming\Issue858-paul\AddedTestProject\UnitTest1.cs:line 29

Disposing the test runner.
Stop time: 10:05 (Total execution time: 3.317 seconds)

2 run, 0 passed, 0 failed, 2 inconclusive, 0 skipped

Original comment by paul.dam...@gmail.com on 24 Apr 2012 at 9:06

GoogleCodeExporter commented 9 years ago
There are few things I want to do less, than debug the VS add-in :(

I'll try and have a look tonight. However, it's quite possible that it will not 
be easily solvable. The VS test process likes to do things "differently".

Original comment by grahamr...@gmail.com on 25 Apr 2012 at 10:26

GoogleCodeExporter commented 9 years ago
:) Thanks

Original comment by paul.dam...@gmail.com on 25 Apr 2012 at 10:29