NUnit的不运行套件测试 [英] NUnit not running Suite tests

查看:363
本文介绍了NUnit的不运行套件测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个测试套件NUnit的引用几个不同的单元测试夹具的各种组件。

I've created a test suite in NUnit that references several distinct unit test fixtures in various assemblies.

我有pretty的很多使用的例子code从的NUnit的文档

I've pretty much used the example code from NUnit's docs:

namespace NUnit.Tests
{
    using System;
    using NUnit.Framework;
    using System.Collections;

    public class AllTests
    {
        [Suite]
        public static IEnumerable Suite
        {
            get
            {
                ArrayList suite = new ArrayList();
                suite.Add(new VisionMap.DotNet.Tests.ManagedInteropTest.DotNetUtilsTest());
                return suite;
            }
        }
    }
}

我的目标是增加几个测试,以上面的列表中,所以我可以在批处理运行它们。

My goal is to add several tests to the list above so I can run them all in a batch.

但是,当我尝试加载的NUnit的图形用户界面的DLL我得到这样的:

But when I try to load the DLL in NUnit's GUI I get this:

我是什么做错了吗?

我知道该文档说的GUI将不会运行的套房,但我已经试过控制台为好。有谁能告诉我什么套房是良好的,我怎么可以用它们来实现我的目标是什么?

I'm aware that the docs say the GUI won't run suites, but I've tried the console as well. Can somebody please tell me what Suites are good for and how I can use them to achieve my goal?

我使用NUnit 2.5.0.9122。

I'm using nunit 2.5.0.9122.

修改

好了,没有答案即将公布。我发现,在最后一个替代的解决方案:分类。 I组测试夹具,给他们适当的类别,然后我可以运行它们在批量的子集,同时还忽略了另外一个子集。

Well, no answers are forthcoming. I found an alternative solution in the end: Categories. I group test fixtures by giving them appropriate categories and then I can run a subset of them in batch, while still ignoring another subset.

不过,很奇怪,这间套房的功能似乎被彻底打破。

Still, very odd that this Suite feature seems to be completely broken.

推荐答案

是不是真的需要什么太大的所有这些天套房。如果你只是想用它们来指定哪些测试做,没有得到执行,这是更好的与类别属性的实现。这是你最后怎么了做什么,听起来像你的问题的最佳解决方案。

Suites aren't really needed for anything much at all these days. If you only wanted to use them to specify which tests do and don't get run this is much better achieved with Category attributes. This is what you ended up doing, and sounds like the best solution to your problem.

不过,对于别人的和未来的参考,您可以仍然使用套房在NUnit的。你必须从控制台运行它们,并且只使用/固定选项。例如,要运行上面指定的套件,你会运行(假设你的类被编译成汇编AllTests.dll):

However, for others' and future reference, you can still use Suites in Nunit. You have to run them from the console, and only using the /fixture option. For example, to run the suite you specified above, you'd run (assuming your class was compiled into an assembly AllTests.dll):

nunit-console /fixture:AllTests.Suite AllTests.dll

您不会看到任何证据或方式在GUI中运行套房 - 这将记入文档。但是,您可以从内置使用命令,像上述的GUI控制台运行它们。

You won't see any evidence of or way to run suites in the GUI - this is noted in the documentation. You can however run them from the console that is built into the GUI using commands like the above.

我用的套房,我的一些测试,因为我有需要我有时需要一个参数传递给我的测试方法的一些奇怪的用例。我这样做是通过创建一个套件,如下面。因此,有一些使用它们,只是没有需要你的情况。

I use suites in some of my testing because I have some odd use cases that require me to sometimes need to pass an argument to my test methods. I do this by creating a suite such as the below. So there are some uses for them, just none needed in your case.

[Suite]
    public static IEnumerable MySuite
    {
        get
        {
            var suite = new ArrayList{new TestClass1(arg1), TestClass2(arg2)};
            return suite;
        }
    }

这篇关于NUnit的不运行套件测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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