API Documentation | All Packages | All Classes | Index | Frames No Frames |
Theories

Package | org.flexunit.experimental.theories
Class | public class Theories
Inheritance | Theories BlockFlexUnit4ClassRunner ParentRunner Object
Implements | IExternalDependencyRunner

The `Theories` runner is a runner that will run theory test methods. In order for a theory to properly run, a test class must have a method marked as a theory method that contains one or more parameters. The type of each parameter must have a static data point or an array of data points that correspond that correspond to that type.

    	 [DataPoints]
    	 [ArrayElementType("String")]
    	 public static var stringValues:Array = ["one","two","three","four","five"];

    	 [DataPoint]
    	 public static var values1:int = 2;

    	 [Theory]
    	 public function testTheory(name:String, value:int):void {
    	 	//Do something
    	 }

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | dependencyWatcher : IExternalRunnerDependencyWatcher [write-only] Setter for a dependency watcher. | Theories
|  | description : IDescription [read-only] Returns an IDescription of the test class that the runner is running, caching it. | ParentRunner
|  | externalDependencyError : String [write-only] Setter to indicate an error occured while attempting to load exteranl dependencies for this test. | Theories

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined By
--- | --- | ---
|  | children : Array [override] [read-only] Returns an array of all methods that have been annotated with Test. | BlockFlexUnit4ClassRunner
|  | name : String [read-only] Returns a name used to describe this Runner. | ParentRunner
|  | stopRequested : Boolean = false private | ParentRunner
|  | testClass : TestClass [read-only] Returns a TestClass object wrapping the class to be executed. | ParentRunner

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | Theories(klass:Class) Constructor. | Theories
|  | filter(filter:IFilter):void Applies the provided Filter to the runner. | ParentRunner
|  | pleaseStop():void Ask that the tests run stop before starting the next test. | ParentRunner
|  | run(notifier:IRunNotifier, previousToken:IAsyncTestToken):void Runs the test class and updates the notifier on the status of running the tests. | ParentRunner
|  | sort(sorter:ISorter):void Applies the provided ISorter to the runner. | ParentRunner

Protected Methods
Show Inherited Protected Methods
Show Inherited Protected Methods

| Method | Defined By
--- | --- | ---
|  | childrenInvoker(notifier:IRunNotifier):IAsyncStatement Returns an IAsyncStatement: Call #runChild(Object, IRunNotifier, AsyncTestToken) on each object returned by #children() (subject to any imposed filter and sort). | ParentRunner
|  | classBlock(notifier:IRunNotifier):IAsyncStatement Constructs an IAsyncStatement to run all of the tests in the test class. | ParentRunner
|  | collectInitializationErrors(errors:Array):void [override] It additionally validates whether specific instances of tests are implemented correctly. | Theories
|  | compare(o1:Object, o2:Object):int This sorting method uses the runner's ISorter to compare two child arguments. | ParentRunner
|  | computeTestMethods():Array [override] Returns the methods that run tests and theories. | Theories
|  | createTest():Object Returns a new fixture for running a test. | BlockFlexUnit4ClassRunner
|  | describeChild(child:*):IDescription [override] Returns an IDescription for child, which can be assumed to be an element of the list returned by ParentRunner#children(). | BlockFlexUnit4ClassRunner
|  | generateDescription():IDescription Returns an IDescription of the test class that the runner is running. | ParentRunner
|  | methodBlock(method:FrameworkMethod):IAsyncStatement [override] Returns a TheoryAnchor for the given theory method in the test class. | Theories
|  | methodInvoker(method:FrameworkMethod, test:Object):IAsyncStatement Returns an IAsyncStatement that invokes method on test | BlockFlexUnit4ClassRunner
|  | possiblyExpectingExceptions(method:FrameworkMethod, test:Object, statement:IAsyncStatement):IAsyncStatement Returns an IAsyncStatement: if method's Test annotation has the expecting attribute, return normally only if next throws an exception of the correct type, and throw an exception otherwise. | BlockFlexUnit4ClassRunner
|  | runChild(child:*, notifier:IRunNotifier, childRunnerToken:AsyncTestToken):void [override] Runs the test corresponding to child, which can be assumed to be an element of the list returned by ParentRunner#children(). | BlockFlexUnit4ClassRunner
|  | validateInstanceMethods(errors:Array):void Adds to errors for each method annotated with Test, Before, or After that is not a public, void instance method with no arguments. | BlockFlexUnit4ClassRunner
|  | validatePublicVoidNoArgMethods(metaDataTag:String, isStatic:Boolean, errors:Array):void Adds to errors if any method in this class is annotated with metaDataTag, but: is not public, or takes parameters, or returns something other than void, or is static (given isStatic is false), or is not static (given isStatic is true). | ParentRunner
|  | validateTestMethods(errors:Array):void [override] Adds to errors for each method annotated with Test or Theory that is not a public, void instance method. | Theories
|  | withAfterClasses():IAsyncStatement Returns an IAsyncStatement: run all non-overridden AfterClass methods on this class and superclasses before executing the statement; all AfterClass methods are always executed: exceptions thrown by previous steps are combined, if necessary, with exceptions from AfterClass methods into a MultipleFailureException. | ParentRunner
|  | withAfters(method:FrameworkMethod, target:Object, statement:IAsyncStatement):IAsyncStatement Returns an IAsyncStatement: run all non-overridden After methods on this class and superclasses before running next; all After methods are always executed: exceptions thrown by previous steps are combined, if necessary, with exceptions from After methods into a MultipleFailureException. | BlockFlexUnit4ClassRunner
|  | withAfterStatements(method:FrameworkMethod, test:Object, statement:IAsyncStatement):IAsyncStatement | BlockFlexUnit4ClassRunner
|  | withBeforeClasses():IAsyncStatement Returns an IAsyncStatement: run all non-overridden BeforeClass methods on this class and superclasses before executing the statement; if any throws an Exception, stop execution and pass the exception on. | ParentRunner
|  | withBefores(method:FrameworkMethod, target:Object, statement:IAsyncStatement):IAsyncStatement Returns an IAsyncStatement: run all non-overridden Before methods on this class and superclasses before running statement; if any throws an Exception, stop execution and pass the exception on. | BlockFlexUnit4ClassRunner
|  | withDecoration(method:FrameworkMethod, test:Object):IAsyncStatement Returns an IAsyncStatement that invokes method on a decorated test. | BlockFlexUnit4ClassRunner
|  | withPotentialAsync(method:FrameworkMethod, test:Object, statement:IAsyncStatement):IAsyncStatement Returns an IAsyncStatement: if method's Test annotation has the async attribute, throw an exception if next encounters an exception during execution. | BlockFlexUnit4ClassRunner
|  | withPotentialRules(method:FrameworkMethod, test:Object, statement:IAsyncStatement):IAsyncStatement Potentially returns a new IAsyncStatement defined by the user on the testcase via the Rule metadata. | BlockFlexUnit4ClassRunner
|  | withPotentialTimeout(method:FrameworkMethod, test:Object, statement:IAsyncStatement):IAsyncStatement Returns an IAsyncStatement: if method's Test annotation has the timeout attribute, throw an exception if next takes more than the specified number of milliseconds. | BlockFlexUnit4ClassRunner
|  | withStackManagement(method:FrameworkMethod, test:Object, statement:IAsyncStatement):IAsyncStatement Returns an IAsyncStatement that manages the stack and allow execution to break across frames. | BlockFlexUnit4ClassRunner

Property Detail

dependencyWatcher | property

`dependencyWatcher:IExternalRunnerDependencyWatcher` [write-only]

Setter for a dependency watcher. This is a class that implements IExternalRunnerDependencyWatcher and watches for any external dependencies (such as loading data) are finalized before execution of tests is allowed to commence.

Implementation
`public function set dependencyWatcher(value:IExternalRunnerDependencyWatcher):void`

externalDependencyError | property |

`externalDependencyError:String` [write-only]

Setter to indicate an error occured while attempting to load exteranl dependencies for this test. It accepts a string to allow the creator of the external dependency loader to pass a viable error string back to the user.

Implementation
`public function set externalDependencyError(value:String):void`
Constructor Detail

Theories | () | Constructor

`public function Theories(klass:Class)`

Constructor.

Parameters

| `klass:Class` — The test class that is to be executed by the runner.

Method Detail

collectInitializationErrors | () | method

`override protected function collectInitializationErrors(errors:Array):void`

It additionally validates whether specific instances of tests are implemented correctly. Adds to `errors` an error for each problem noted with the test class (available from `#testClass()`). Default implementation adds an error for each method annotated with `BeforeClass` or `AfterClass` that is not `public static void` with no arguments.

Parameters

| `errors:Array` — An `Array` of issues encountered when attempting to setup the runner for the test class.

computeTestMethods | () | method |

`override protected function computeTestMethods():Array`

Returns the methods that run tests and theories. The tests will be located at the begining of the returned array while the theories will be present at the end of the array.

Returns

| `Array`

methodBlock | () | method |

`override protected function methodBlock(method:FrameworkMethod):IAsyncStatement`

Returns a `TheoryAnchor` for the given theory method in the test class.

Parameters

| `method:FrameworkMethod` — The theory method that is to be tested.

Returns

| `IAsyncStatement` — a `TheoryAnchor` for the provided `FrameworkMethod`.

validateTestMethods | () | method |

`override protected function validateTestMethods(errors:Array):void`

Adds to `errors` for each method annotated with `Test` or `Theory` that is not a public, void instance method.

Parameters

| `errors:Array`

Thu Apr 10 2014, 08:07 AM +10:00