0
votes

I am trying to test a Windows Phone 7.1 class library with NUnit and the standard console (GUI or not GUI) runner.

After my problem, related below I have found this one: http://dotneteers.net/blogs/vbandi/archive/2012/08/08/using-nunit-to-test-windows-phone-7-applications-part-1.aspx

So I am almost sure this is a silly problem at my own.

Every time I try to load my assembly testing I get this error:

System.TypeLoadException: Cannot load type 'System.Runtime.Versioning.TargetFrameworkAttribute' from assembly'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

For futher information, use the Exception Details menu item.

* Here 'Details' *

System.TypeLoadException...

Server stack trace: en System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount) en System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) en System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) en System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, Module decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, RuntimeMethodHandle& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) en System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes) en System.Reflection.CustomAttribute.GetCustomAttributes(Assembly assembly, RuntimeType caType) en System.Reflection.Assembly.GetCustomAttributes(Type attributeType, Boolean inherit) en NUnit.Core.ActionsHelper.GetActionsFromAttributeProvider(ICustomAttributeProvider attributeProvider) en NUnit.Core.TestAssembly..ctor(Assembly assembly, String path) en NUnit.Core.Builders.TestAssemblyBuilder.BuildTestAssembly(Assembly assembly, String assemblyName, IList fixtures, Boolean autoSuites)
en NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites) en NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites) en NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
en NUnit.Core.TestSuiteBuilder.Build(TestPackage package) en NUnit.Core.SimpleTestRunner.Load(TestPackage package) en NUnit.Core.ProxyTestRunner.Load(TestPackage package) en NUnit.Core.ProxyTestRunner.Load(TestPackage package) en NUnit.Core.RemoteTestRunner.Load(TestPackage package) en System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) en System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs) en System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

Exception rethrown at [0]: en System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) en System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) en NUnit.Core.TestRunner.Load(TestPackage package) en NUnit.Util.TestDomain.Load(TestPackage package) en NUnit.Util.TestLoader.LoadTest(String testName)

Somebody know what is the problem I'm not be able to find ?

1

1 Answers

0
votes

I have found (in a very easy to explain way) what is the problem and what is the solution (or better said the alternative).

The problem is that NUnit Console Runner (or GUI runner), execute under a different environment. I mean a Console Application or a Winforms application and then they try to load a Windows Phone library and that is the problem.

The solution is execute the tests with Re-Sharper, NCrunch, Visual NUnit or something similar and NOT use NUnit default runners.

I'm using Visual NUnit. http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099

:-)

Regards and thanks to all people reading my question.