Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

  • Right click on your src folder and select New -> Test Suite Class name this class "SampleSuite" and change the package to sampleSuite click finish.
  • Open the SampleSuite.as file
  • Import the TestCase1 class you just created with the following code:
    Code Block
    actionscript
    actionscript
    import sampleSuite.tests.TestCase1;
    
  • Declare variables for the test case classes, to register your test cases in this suite. Your code should look like this: \
    Code Block
    actionscript
    actionscript
    [Suite]
    [RunWith("org.flexunit.runners.Suite")]
    public class SampleSuite
    {
         public var t1:TestCase1;    
    }
    
    Wiki Markup
  • [Suite]\ notifies FlexUnit 4 that this class is a suite and to expect:
  • Wiki Markup\[\[RunWith|\[RunWith("org.flexunit.runners.Suite")\]\]\] which specifies what runner to use for this test class. Most of the time this is the runner you will want to use. However, FlexUnit 4 allows the use of custom runners. \ [\[RunWith|\[RunWith("")\]\]\] is where this custom runner would be specified.
    '''Note:''' When declaring your test classes, ''always'' declare the variable as public otherwise FlexUnit 4 will not be able to run them!

Running your tests

You may of course have your unit tests run several different ways if you prefer. Any number of listeners may be added to your test run. Also, any number of suites can be added to your Runner and run consecutively. For this tutorial we will discuss how to go about using Flash Builder's internal process of running tests and suites. If you wish to learn about the other options, please see the [Test Runner] section.

...