.net - 海洋单元测试

标签 .net nunit ocean

当我尝试从 Ocean SDK 运行单元测试示例时,在尝试加载 NUnit.exe 中的 dll 时出现错误。 谁能帮忙看看是什么原因?

NUnit.exe 出现以下异常:

System.IO.FileNotFoundException...

Server stack trace: 
   at System.ModuleHandle.ResolveType(Int32 typeToken, RuntimeTypeHandle* typeInstArgs, Int32 typeInstCount, RuntimeTypeHandle* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveTypeHandle(Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.Module.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at 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)
   at System.Reflection.CustomAttribute.GetCustomAttributes(Module decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
   at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
   at NUnit.Core.CoreExtensions.InstallAdhocExtensions(Assembly assembly)
   at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
   at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
   at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
   at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
   at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
   at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)

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.Load(TestPackage package)
   at NUnit.Util.TestDomain.Load(TestPackage package)
   at NUnit.Util.TestLoader.LoadTest(String testName)

最佳答案

此案例已通过 Ocean Dev 解决。正如我们发现的,(仔细地)遵循示例自述文件中的所有说明非常重要,例如,“确保将其他测试程序集复制到 petrel 根” – 不仅意味着 NUnit 根的 DLL,还意味着 lib-子文件夹。发现了两个“不清楚”的点:1)nunit.exe.config 中的 ProbingPath 必须由 Petrel 的 ProbingPath 扩展但未被替换;2)出于某种原因,用户可能需要复制 NUnit“framework”子文件夹的内容也进入海燕根。

关于.net - 海洋单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8398931/

相关文章:

.net - 检索 Windows "Window Color"

c# - 针对多个版本的 .NET 框架的最佳方式是什么?

c# - XDocument 保存 & 而不仅仅是 &

unit-testing - NUnit:在命令行上指定要运行的夹具时不使用全局设置夹具

c# - 创建一个 NUnit 约束,意思是 "{collection} does not contain {item}"

ocean - 无法在 petrel 2013 中调试我的插件

ocean - 如何知道项目何时完成打开

c# - 改进 Azure 表存储更新插入

visual-studio - 使用 NUnit,我需要使用 Visual Studio 中的哪种项目类型来创建我的测试项目?

ocean - 在虚拟机中运行 Petrel?