This page last changed on Jul 02, 2005 by peli.

A TestSuite is a fixture populated at runtime, a dynamic fixture. A TestSuite can be filled with any number of TestCase.

A good example of 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 TestSuiteFixtureAttribute attribute. Each method which creates suite must be tagged with TestSuiteAttribute and return a TestSuite. Of course, there can be multiple methods returning suites.

A TestSuite can be filled with ITestCase implementation, whether you implement your own version or you use the built-in implementations.

Unable to find source-code formatter for language: cs. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
using System;
using MbUnit.Core.Framework;
using MbUnit.Framework;
namespace MyNamespace
{
    [TestSuiteFixture]
    public class MyClass
    {
        public delegate void TestDelegate(Object context);

        [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);
        }
    }
}
Document generated by Confluence on Jun 11, 2007 11:56