You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

''Attributes:'' none, other than the fully qualified class name of the runner.

''RunWith - metadata tag that is used to tell FlexUnit4 to run with a specified runner''

What is RunWith?

RunWith is a piece of Metadata that, if it is used, tells FlexBuilder4 to use the runner that is specified in the fully qualified path that is part of the RunWith metadata.

The runner that is used must implement IRunner. For more information about runners, check out Runners and Builders and the section on Architecture.

An example of RunWith being used with a Suite

The Suite metadata must be used with the RunWith tag as well, to tell FlexUnit4 to use the FlexUnit4 suite runner. This will change in the future so that only the Suite tag is needed.

     [Suite]
     [RunWith("org.flexunit.runners.Suite")]
     public class G11NCalendarSuite
     { 
          public var t1:CalendarCase;
          public var t2:BoxCase; 
          
          public var t3:HorizontalRuleCase;
     }

An example of RunWith being used with Theories

     [RunWith("org.flexunit.experimental.theories.Theories")]
     public class CalendarTheory extends G11nAbstractMatcherTestCase
     {
          [DataPoints]
          public static var numbers : Array = [1, 2, 3, 4, 5];

          [Theory]
          public function addNumbers( num1 : int, num2 : int ):void
          {
          Assert.assertEquals( num1, num2 );
          }
     }

An example of RunWith being used with Parameterized

package flexUnitTests
{
     import org.flexunit.asserts.assertEquals;
     import org.flexunit.runners.Parameterized;

     [RunWith("org.flexunit.runners.Parameterized")]
     public class MyTest
     {         
          [Parameters]
          public static var data2:Array = [ [10, 10], [10, 10], [10, 10] ];

          private var myRunner:Parameterized;
          
          private var _input:int;
     
          private var _expected:int;
          
          [Test]
          public function myTest():void{
               assertEquals(_input, _expected);
          }
          
          public function MyTest(param1:int, param2:int) {
               _input = param1;
               _expected = param2;
          }
     }
}
  • No labels