配置 NUnit 命令行以运行 MonoTouch 测试

发布于 2024-09-26 02:16:43 字数 788 浏览 6 评论 0原文

我的 MonoTouch 项目中有一个单元测试,但无法从 MonoDevelop 内部运行 - 它因“Unix 传输错误”而失败。在网上查了一下,这似乎与 NUnit 测试运行程序崩溃有关,所以我想我应该尝试使用命令行测试运行程序。

我使用 MonoDevelop 的“Create Package”来构建和打包所有 DLL,然后尝试使用 nunit-console FooTest.dll 运行我的测试。这会爆炸,但我很确定它与 MonoDevelop 内部爆炸的原因不同。我收到的错误消息是:

** (/Library/Frameworks/Mono.framework/Versions/2.6.7/lib/mono/1.0/nunit-  
console.exe:11174): WARNING **: The class System.Action`1 could not be loaded,
used in mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
File or assembly name FooTest, Version=0.0.0.0, Culture=neutral, 
PublicKeyToken=null, or one of its dependencies, was not found.

我对这里的所有内容都很陌生——NUnit、MonoTouch、MonoDevelop 和.NET——但看起来我需要以某种方式配置 NUnit 以使用 MonoTouch 运行时环境。是这样吗?如果是这样,我该怎么做?

I've got a unit test in my MonoTouch project that I can't run from inside MonoDevelop -- it fails with "Unix transport error." Poking around on the web it looks like that's associated with the NUnit test runner blowing up, so I thought I'd try using the command-line test runner.

I used MonoDevelop's "Create Package" to build and package up all the DLLs, and then tried running my tests with nunit-console FooTest.dll. This blows up, but I'm pretty sure it's not for the same reason it blows up inside MonoDevelop. The error message I get is:

** (/Library/Frameworks/Mono.framework/Versions/2.6.7/lib/mono/1.0/nunit-  
console.exe:11174): WARNING **: The class System.Action`1 could not be loaded,
used in mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
File or assembly name FooTest, Version=0.0.0.0, Culture=neutral, 
PublicKeyToken=null, or one of its dependencies, was not found.

I'm new to everything here -- NUnit, MonoTouch, MonoDevelop and .NET -- but it looks like I need to somehow configure NUnit to use the MonoTouch runtime environment. Is that it? And if so, how do I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

垂暮老矣 2024-10-03 02:16:43

没有将 NUnit 与 MonoTouch 结合使用的好方法。

  • 目前还没有可以在 iPhone 或模拟器中运行的 NUnit 测试运行程序。
  • 您可以使用 Mono 在 Mac 上运行的 NUnit 来测试 MonoTouch dll,但不能使用这些程序集中的任何 iOS 库。这意味着您无法测试控制器,只能测试没有 UIKit 内容的后端模型逻辑。

抱歉,我自己也有同样的痛苦。如果有解决方案出现,我会回复。

There isn't a good way to use NUnit with MonoTouch.

  • There isn't currently an NUnit test runner that will run on the iPhone or in the simulator
  • You can test MonoTouch dlls with NUnit running on the Mac with Mono, but you can't use any iOS libraries from those assemblies. This means you can't test your controllers, only backend Model logic with no UIKit stuff.

Sorry, I have felt the same pain myself. I will post back if a solution ever surfaces.

待天淡蓝洁白时 2024-10-03 02:16:43

将 $MONO_PATH 设置为 nunit 库以便能够运行 nunit-console。在我的机器上, $MONO_PATH 声明是(在我的 .profile 文件中):

MONO_PATH='/Applications/Beta/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/:$MONO_PATH'

set $MONO_PATH to the nunit library to be able to run nunit-console. On my machine, the $MONO_PATH declaration is (in my .profile file):

MONO_PATH='/Applications/Beta/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/:$MONO_PATH'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文