为NUnit构建的测试dll“不是NUnit测试”(包括答案​​)

时间:2012-05-24 15:07:39

标签: exception testing nunit

关于在输出窗口中获取此信息,有another question on SO。他们的答案涉及GAC和dll版本。我的答案特定于我的情况,即使它表现出相同的症状。

输出窗口 - 测试

'E:\CodeRepository-Git\DFBAzure\AzureMgmtServiceDashboard\Wp7AzureMgmt.DashboardFeeds.Test\bin\Debug\Wp7AzureMgmt.DashboardFeeds.Test.dll' is not a NUnit Test

我的问题是App.config对一个众所周知的密钥有一个格式错误的值。我已经在MVC web.config中纠正了这个问题但是忘了在test.dll中修复它。

当我试图从NUnit gui运行dll(项目确实加载)时,gui抛出了一个未处理的异常。细节是:

 See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.Configuration.ConfigurationErrorsException: The configSource attribute must be a relative physical path, so the '/' character is not allowed. (E:\CodeRepository-Git\DFBAzure\AzureMgmtServiceDashboard\Wp7AzureMgmt.DashboardFeeds.Test\bin\Debug\Wp7AzureMgmt.DashboardFeeds.Test.dll.config line 12)
   at System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors(Boolean ignoreLocal)
   at System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors(ConfigurationSchemaErrors schemaErrors)
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   --- End of inner exception stack trace ---

Server stack trace: 
   at System.Configuration.ClientConfigurationSystem.EnsureInit(String configKey)
   at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.Configuration.PrivilegedConfigurationManager.GetSection(String sectionName)
   at System.Net.Configuration.SettingsSectionInternal.get_Section()
   at System.Net.Sockets.Socket.InitializeSockets()
   at System.Net.IPAddress.InternalParse(String ipString, Boolean tryParse)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink..ctor(String channelURI, TcpClientChannel channel)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSinkProvider.CreateSink(IChannelSender channel, String url, Object remoteChannelData)
   at System.Runtime.Remoting.Channels.BinaryClientFormatterSinkProvider.CreateSink(IChannelSender channel, String url, Object remoteChannelData)
   at System.Runtime.Remoting.Channels.Tcp.TcpClientChannel.CreateMessageSink(String url, Object remoteChannelData, String& objectURI)
   at System.Runtime.Remoting.RemotingConfigHandler.FindDelayLoadChannelForCreateMessageSink(String url, Object data, String& objectURI)
   at System.Runtime.Remoting.RemotingServices.CreateEnvoyAndChannelSinks(MarshalByRefObject tpOrObject, ObjRef objectRef, IMessageSink& chnlSink, IMessageSink& envoySink)
   at System.Runtime.Remoting.RemotingServices.InternalUnmarshal(ObjRef objectRef, Object proxy, Boolean fRefine)
   at System.Runtime.Remoting.ObjRef.GetRealObjectHelper()
   at System.Runtime.Serialization.ObjectManager.ResolveObjectReference(ObjectHolder holder)
   at System.Runtime.Serialization.ObjectManager.DoFixups()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.DeserializeObject(MemoryStream stm)
   at System.Runtime.Remoting.Messaging.SmuggledMethodCallMessage.FixupForNewAppDomain()
   at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoDispatch(Byte[] reqStmBuff, SmuggledMethodCallMessage smuggledMcm, SmuggledMethodReturnMessage& smuggledMrm)
   at System.Runtime.Remoting.Channels.CrossAppDomainSink.DoTransitionDispatchCallback(Object[] args)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.BeginRun(EventListener listener, ITestFilter filter, Boolean captureTrace, LoggingThreshold logLevel)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)

Exception rethrown at [1]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at NUnit.Core.TestRunner.BeginRun(EventListener listener, ITestFilter filter, Boolean captureTrace, LoggingThreshold logLevel)
   at NUnit.Core.ProxyTestRunner.BeginRun(EventListener listener, ITestFilter filter, Boolean tracing, LoggingThreshold logLevel)
   at NUnit.Util.TestLoader.RunTests(ITestFilter filter)
   at NUnit.UiKit.TestSuiteTreeView.RunTests(ITest[] tests, Boolean ignoreCategories)
   at NUnit.Gui.NUnitForm.runButton_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
nunit
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/nunit.exe
----------------------------------------
nunit-gui-runner
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/lib/nunit-gui-runner.DLL
----------------------------------------
nunit.core
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/lib/nunit.core.DLL
----------------------------------------
nunit.util
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/lib/nunit.util.DLL
----------------------------------------
nunit.core.interfaces
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/lib/nunit.core.interfaces.DLL
----------------------------------------
nunit.uikit
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/lib/nunit.uikit.DLL
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5458 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Runtime.Remoting
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll
----------------------------------------
nunit.uiexception
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.6.0.12051
    CodeBase: file:///C:/Program%20Files%20(x86)/NUnit%202.6/bin/lib/nunit.uiexception.DLL
----------------------------------------
System.Web
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_64/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll
----------------------------------------
vg5zflea
    Assembly Version: 2.6.0.12051
    Win32 Version: 2.0.50727.5456 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

1 个答案:

答案 0 :(得分:0)

以下是我的回答:

重要的一点是:

The configSource attribute must be a relative physical path, so the '/' character is not allowed.

当我最终停止查看NUnit版本和GAC时,通过简单的修复解决了我的问题。