Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NUnit not running Suite tests

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

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.

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

What am I doing wrong?

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?

I'm using nunit 2.5.0.9122.

Edit

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.

like image 602
Assaf Lavie Avatar asked May 27 '10 08:05

Assaf Lavie


1 Answers

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.

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

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;
        }
    }
like image 61
imoatama Avatar answered Sep 20 '22 06:09

imoatama