Runners and Builders
understanding the different Builders and the Runners created by them.
What are Builders?
Builders are a series of classes that are used by the FlexUnit 4 to create Runners for each TestSuite and TestCase. ClassRequest is responsible for creating an AllDefaultPossibilitiesBuilder which will go one by one through a list of Builders until it a compatible Runner is found. This process continues recursively through every child class.
- The following is the list of default builders and the order in which they're run against each test within the Request. For more information on what the builder is looking for please click each builder's linked page.
IgnoredBuilder - The builder responsible for handling tests marked as
[Ignore] and returns an instance IgnoredClassRunner class
MetaDataBuilder - The builder responsible for handling
[RunWith] metadata tags and returns an instance of the IRunner class that was specified in the given, if it can be found.
Note: This is the main point of extensibility in the framework, since any custom written IRunner class can be used.
SuiteMethodBuilder - The builder responsible for handling FlexUnit .9 suite classes and returns an instance of the SuiteMethod class
FlexUnit1Builder - The builder responsible for handling FlexUnit .9 test classes and returns an instance of the FlexUnit1ClassRunner class
Fluint1Builder - The builder responsible for handling Fluint 1 test classes and returns an instance of the Fluint1ClassRunner class
FlexUnit4Builder - The catch-all builder which is responsible for handling all unhandled classes most specifically FlexUnit 4 test cases and returns an instance of the BlockFlexUnit4ClassRunner class
What are Runners?
Runners are classes that implement IRunner, and have the capability to run specific types of suites, tests, or methods. Simple Runners are rather easy to setup and only require a get description method and an implementation of the run() method.
IRunner is an interface implemented by any object capable of executing a specific type of test
For example, there is a runner that understands the work needed to execute a suite. A separate runner understands how to execute test cases and methods. To determine the correct IRunner for the request, the Request object kicks off a recursive process of introspecting each class.
- Introspect the class
- Identify the runner for the class
- Identify any children
- Run this process on each child to identify their correct runner
- Return the top level runner for the Request
FlexUnit 4 determines the correct runner for each class using builders which are objects responsible for building the correct runner for a class. We try multiple possible builders until a compatible one is identified.
- Ignored Builder
- MetaData Builder
- Suite Method Builder
- Flex Unit 1 Builder
- Fluint 1 Builder
- FlexUnit 4 Builder
IgnoredClassRunner -- A simple Runner that provides a simple description and run() method that notifies a test is ignored.
Suite -- The Runner that understands how to execute FlexUnit 4 Suite classes.
TheoryBlockRunner -- The Runner that understands how to execute FlexUnit 4 Theory classes and extends from BlockFlexUnit4ClassRunner
SuiteMethod -- The Runner that understands how to execute FlexUnit .9 suite classes.
FlexUnit1ClassRunner -- The Runner that understands how to execute FlexUnit .9 test classes.
Fluint1ClassRunner -- The Runner that understands how to execute Fluint 1 test classes.
BlockFlexUnit4ClassRunner -- The Runner that understands how to execute FlexUnit 4 Test classes.
ParentRunner -- The super class to BlockFlexUnit4ClassRunner, responsible for running the sequence of Befores, Afters, and Tests.
IRunNotifiers are a type of class that FlexUnit 4 uses to notify others of an event that occurred during testing. It's similar to an IEventDispatcher.
The IRunner class uses these IRunNotifiers to notify of the following conditions:
TestRun: Started/Finished Test: Started/Failed/Ignored/Finished/AssumptionFailures
Unlike an event dispatcher IRunNotifiers have limitations on what type of objects they can listen to for events. IRunNotifier has two methods to set a listener, addListener() and removeListener() that both accept an IRunListener as an argument.
While there is generally only one IRunNotifier present in the system at any given time, there can be multiple IRunListeners. The IRunListeners listen to these messages and optionally perform some action.
Now that you're aware of all the Runners that available in FlexUnit 4, you probably noticed that there is legacy support for Fluint and FlexUnit .9 tests. Since FlexUnit 4 has full backwards support for FlexUnit .9 and Fluint 1 Runners it is possible to integrate tests and suites directly into your FlexUnit 4 suites with no code changes necessary.
In future versions of FlexUnit 4 additional adapters will be provided. If you have written an adapter, submit it!