...
For our purposes:
Test Method
A TestMethod is the smallest unit of the testing framework. A test method executes code and checks an outcome. At the end of the test method we generally make an assertion, stating our beliefs about the state of this particular test method if all worked as planned. We might expect a value to be true or false, null or not null, perhaps even equal to another variable, or simply not in a list of acceptable values. If the assertion is valid, the test passes. If the assertion does not represent reality (we specify it should be false but it is really true), the test fails.
...
Code Block | ||||
---|---|---|---|---|
| ||||
[Ignore("Not Ready to Run")] [Test] public function multiplication():void {} |
Test Case
A TestCase is a collection of [TestMethod|TestMethods] that share a common test environment. When using FlexUnit4, each \ [TestCase\] can have a [\[Before\] | FlexUnit Metadata#Before ] and [\[After\] | FlexUnit Metadata#After] metadata tags that can be used to decorate methods you want to run before and/or after each test method. These metadatas simulate the <code>setUp{{ setUp()</code> and <code>tearDown()</code> methods of [Fluint | http://fluint.googlecode.com/] and FlexUnit .9 | [}} and {{ tearDown()}} methods of Fluint and FlexUnit .9 | http://code.google.com/p/as3flexunitlib/]. So, for example, if you wanted to write a series of [TestMethods| FlexUnit TestMethod] to test the Flex Timer class, they could all exist in a single TestCase. In the method decorated with [\[Before\] | FlexUnit Metadata#Before] you would create a Timer instance to test use in your tests. In the method decorated with [\[After\] | FlexUnit Metadata#After] , you would stop that timer and remove references so it can be garbage collected.
Wiki Markup
Additionally, you may decorate any number of static methods per class with the medatadata [\[BeforeClass\] | FlexUnit Metadata#BeforeClass ] and [\[AfterClass\] | FlexUnit Metadata#AfterClass]. These methods will be run once per test class.unmigrated-wiki-markup
For example, if your TestCase has two [TestMethods| FlexUnit TestMethod], the FlexUnit4 framework would execute the \ [TestCase\] in the following way:
...
\*The [\[Before\]| FlexUnit Metadata#Before] method is run before every \[TestMethod\] and the [\[After\]| FlexUnit Metadata#After] method is run after every [TestMethod].
'''Note:''' In a TestCase tests may be executed in ANY order. If you would like to specify an order to the tests, you may do so, see order for instructions on how to do so.
Test Suite
Finally, a [TestSuite] is a collection of [TestCase|TestCases] and possibly other [TestSuite|FlexUnit TestSuites]. A test suite is a simple class marked with a [\[Suite\] | FlexUnit Metadata#Suite], and \[RunWith\|[RunWith("org.flexunit.runners.Suite")|RunWith("org.flexunit.runners.Suite")\]] [FlexUnitMetadata |Metadata] tags. The tests and other suites that you want to have run inside this suite must be declared as public (and only public) variables. For example: Wiki Markup
Code Block | ||||
---|---|---|---|---|
| ||||
[Suite] [RunWith("org.flexunit.runners.Suite")] public class SampleSuite { public var otherSuite1 : SampleOtherSuite; public var test : SampleTest; public var test1 : SampleAsyncTest; } |
...