Re: How to group tests in one assembly?

"Charlie Poole" <[email protected]>
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <010501c86ff7$eafd8e70$6401a8c0@ferrari>
Hi Artur,
 
See my earlier note for the recommended approach.
 
The way you are doing it here has a number of issues, the biggest one being
that your tests won't show up in the gui without some special command-line
tricks. :-)
 
This is an older way of combining tests that pre-dates the namespace
approach I described. Some people still use if for legacy reasons or because
of (very) unusual situations they need to deal with.
 
I recommend trying the standard (namespace) approach first.
 
If you find there is some reason to do it with a suite, I suggest moving to
a current version of NUnit and using the approach that allows you to create
a suite without referencing the nunit core. That has other problems. Note
that the NUnit 2.2 series has had no features added for about two years and
is in pure maintenance mode now.
 
See the latest docs for info on the old (what you used) and new approaches
to using Suite... http://nunit.org/?p=suite
<http://nunit.org/?p=suite&r=2.4.6> &r=2.4.6
 
Charlie


  _____  

From: [email protected]
[mailto:[email protected]] On Behalf Of Artur Futuro
Sent: Friday, February 15, 2008 5:28 AM
To: [email protected]
Subject: Re: [Nunit-users] How to group tests in one assembly?


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.