BlockFlexUnit4ClassRunner

The BlockFlexUnit4ClassRunner is the heart of running FlexUnit4 tests. It is responsible for iterating through tests in a given class, determining if they are being implemented correctly, and executing them.

The following flow occurs for a provided class:

  • Any methods that contain a medadata tag of [BeforeClass] are executed.
  • Once the [BeforeClass] methods have finished, each method labeled as [Test] is sequenced with all methods that contain [Before] and [After] and variables with [Rule] metadata tags Before each test, all class variables marked as [Rule] will be executed followed by all methods marked as a [Before] method. After this occurs, the actual test method will execute. After the test has finished, regardless of whether it succeeded or failed, all class variables marked as [Rule] will execute followed by all methods marked as an [After] method. This procedure will be repeated for all tests in the class.
  • Any methods that contain a metadata tag of [AfterClass] are finally executed.

While running tests, the BlockFlexUnit4ClassRunner uses two very important concepts: recursive sequences and decoration.

The first sequence that is used in the BlockFlexUnit4ClassRunner is that of the before class sequence, the tests sequence, and after class sequence. Both the before class and after class sequences consist of the before class and after class methods. The tests sequence consists of a sequence of individual test sequences. Each individual test sequence contains the before sequence, the test, and the after sequence. The before and after sequences contain the before and after methods.

Before any before class, after class, before, after, rule or test methods are executed, they are decorated in order to add functionality. These decorations are used to wrap the invocation of a method with code that should be executed before or after the method in a synchronous nature. Each decorator is applied to the method if necessary; if it is not needed, the decorator is not applied.

Back

  • No labels