在MonoDevelop 2.4中使用NUnit测试Monotouch应用 [英] Testing a Monotouch app with NUnit in MonoDevelop 2.4

查看:66
本文介绍了在MonoDevelop 2.4中使用NUnit测试Monotouch应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Monotouch和Monodevelop的新手.尝试开始使用NUnit时,我遇到了很多麻烦-我在网上找不到的任何粗略参考似乎都与我在UI中看到的东西相匹配(在Mac OS 10.6上为MonoDevelop 2.4).我尝试过:

I'm new to both Monotouch and Monodevelop. Trying to get started with NUnit and I'm having a lot of trouble -- none of the sketchy references I can find on line seem to match what I'm seeing in the UI (MonoDevelop 2.4 on Mac OS 10.6). I've tried:

  1. 在我的解决方案中添加一个"NUnit组装测试集合"项目.
  2. 向我的解决方案中添加一个空MonoTouch项目"项目,然后向其添加NUnit程序集,并添加我的主项目作为参考.
  3. 在我的解决方案中添加一个C#空项目",并添加NUnit,MonoTouch和我自己的项目作为引用.这会产生一个生成错误,抱怨'[测试项目名称] .exe'不包含适用于入口点的静态'Main'方法."

(1)产生了一种奇怪的项目,我只能向其中添加程序集-没有引用,当然也没有测试.

(1) produces a strange sort of project to which I can only add assemblies -- no references and certainly no tests.

(2)和(3)的行为几乎完全相同:

(2) and (3) behave pretty much identically:

  • 首先,一个构建错误抱怨没有静态的"Main"方法.我可以通过在Build-> General project options中将编译目标更改为"Library"来解决此问题.
  • 接下来,当我尝试运行测试(从单元测试"选项卡中)时,它说它正在使用"Debug | iPhoneSimulator"配置运行它们.
  • 测试结果"面板显示此正在运行测试"消息,而不会显示任何其他输出.
  • 计数保持在测试:0失败:0忽略:0".

很明显,我在这里做错了什么,但是我应该怎么做?

Clearly I'm doing something wrong here, but what am I supposed to be doing?

只是笑了,这是我的考验.

Just for grins, here's my test.

using System;
using NUnit.Framework;
namespace mynamespace
{ 
    [TestFixture]
    public class NavItemTest
    {
        [Test]
        public void TestAll()
        {
           Assert.AreEqual(4, NavItem.all().Count);
        }
    }
}

推荐答案

如果您错过了它,现在可以为MonoTouch使用NUnitLite运行器,该运行器旨在用于UI不可知代码,并在设备(或模拟器)上执行.

In case you missed it, there is now a NUnitLite runner available for MonoTouch which is designed to work for UI agnostic code and executed on devices (or simulator).

请参阅:用于iOS的.NET单元测试运行器

这篇关于在MonoDevelop 2.4中使用NUnit测试Monotouch应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆