Re: How to group tests in one assembly?

"Artur Futuro" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
Ok I found the solution. To do that you should:

1. Create assembly project in C# ( Library Class in VS 2005 )
2. In the main class add a code:

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

    public class AllTests
    {
        [Suite]
        public static TestSuite NameOfSuite
        {
            get
            {
                TestSuite suite = new TestSuite("All Tests");
                suite.Add(new Class1());
                suite.Add(new Class2());
                suite.Add(new Class3());
                suite.Add(new Class4());
                return suite;
            }
        }
    }
}

3. Add reference to nunit.framework.dll and  nunit.core.dll.
4. Add to project classes Class1, Class2, Class3, Class4 etc. with an
example content:

using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;

    [TestFixture]
    public class Class1
    {

        [Test]
        public void test1()
        {
            Assertion.AssertEquals(2, 2);
        }

        [Test]
        public void test3()
        {
            Assertion.AssertEquals(2, 2);
        }

        [Test]
        public void test2()
        {
            Assertion.AssertEquals(2, 2);
        }
    }

(WARNING!! It is important that classes added to suite (TestSuite) should be
public. Above solution works on NUnit-Net-2.0 2.2.10 )

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/

_______________________________________________
Nunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nunit-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.