Dashboard > MbUnit > ... > MbUnit Home > TestSuiteFixture
  MbUnit Log In View a printable version of the current page.  
  TestSuiteFixture
Added by Jonathan de Halleux, last edited by Graham Hay on Jun 21, 2007  (view change)
Labels: 
(None)

A TestSuite is a fixture populated at runtime, a dynamic fixture. A TestSuite can be filled with any number of [TestCase]s, a good example of a TestSuite application is [DataDrivenTesting] where you want to create a [TestCase] for each data entry.

How-to

To use suites, tag your class with the TestSuiteFixture attribute. Each method that creates a suite must be tagged with the [TestSuiteAttribute] and return a TestSuite. Of course, there can be multiple methods returning suites.

A TestSuite needs to be populated with implementations of ITestCase, whether you use the provided versions or create your own. If you tag a method with the [TestSuiteSetUp] attribute it will be run before your TestSuites are generated (v2.4.1+).

using System;

using MbUnit.Core.Framework;
using MbUnit.Framework;

namespace MyNamespace
{
    [TestSuiteFixture]
    public class MyClass
    {
        public delegate void TestDelegate(Object context);

        [TestSuiteSetUp]
        public void SetUp
        {
            ...
        }

        [TestSuite]  
        public TestSuite GetSuite()
        {
            TestSuite suite = new TestSuite("Suite1");

            suite.Add( "Test1", new TestDelegate( this.Test ), "hello" );
            suite.Add( "Test2", new TestDelegate( this.AnotherTest), "another test" );

            return suite;
        }

        public void Test( object testContext )
        {
            Console.WriteLine("Test");
            Assert.AreEqual("hello", testContext);
        }

        public void AnotherTest( object testContext )
        { 
           Console.WriteLine("AnotherTest");
           Assert.AreEqual("another test", testContext);
        }
    }
}
ITestCase (MbUnit)
TestSuite (MbUnit)

Site powered by a free Open Source Project / Non-profit License (more) of Confluence - the Enterprise wiki.
Learn more or evaluate Confluence for your organisation.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.2.9 Build:#527 Sep 07, 2006) - Bug/feature request - Contact Administrators