Inherits from NSObject
Declared in KIFTestController.h

Overview

@class KIFTestController

The KIFTestController class is the test runner for KIF integration tests. It should be configured with a list of KIFTestScenarios to run. It will run the scenarios sequentially, aborting any given scenario and moving on to the next if a step in the scenario fails.

The controller can be set up in one of two primary ways:

Subclassing (Preferred) Create a subclass of KIFTestController for your application. This class will encapsulate the logic of which scenarios to run, and helps minimize the amount of testing code within your core application. Your subclass should override the -initializeScenarios method, and in that method the scenarios to run should be created and added to the controller using -addScenario:. The -initializeScenarios method will be called automatically as part of starting the testing. To start running the tests, your application code then just needs to call the code below.

    [[YOURTestController sharedInstance] startTestingWithCompletionBlock:nil];
   

Construction You can initialize the test controller without subclassing by iteratively creating and adding scenarios (using -addScenario:) somewhere in your application code. You can then start testing by calling the code below.

    [[KIFTestController sharedInstance] startTestingWithCompletionBlock:nil];
   

Tasks

Properties

currentScenario

@property (nonatomic, readonly, retain) KIFTestScenario *currentScenario
Discussion

@property currentScenario

Declared In

KIFTestController.h

currentStep

@property (nonatomic, readonly, retain) KIFTestStep *currentStep
Discussion

@property currentStep

Declared In

KIFTestController.h

failureCount

@property (nonatomic, readonly) NSInteger failureCount
Discussion

@property failureCount

Declared In

KIFTestController.h

scenarios

@property (nonatomic, readonly, retain) NSArray *scenarios
Discussion

@property scenarios

You can add scenarios to the testing suite using addScenario:

Declared In

KIFTestController.h

testing

@property (nonatomic, readonly, getter=isTesting) BOOL testing
Discussion

@property testing

Declared In

KIFTestController.h

Class Methods

sharedInstance

+ (id)sharedInstance
Discussion

@method sharedInstance

The test controller class should never be allocated manually. You should always use the singleton retrieved using this method. If you subclass KIFTestController, then you should invoke your subclass’s version of this class method to insure that the singleton is of the correct class type.

Return Value

The singleton instance of the test controller.

Declared In

KIFTestController.h

Instance Methods

addAllScenarios

- (void)addAllScenarios
Discussion

@method addAllScenarios

This enumerates the list of class methods on KIFTestScenario and adds those starting with “scenario” alphabetically.

Declared In

KIFTestController.h

addAllScenariosWithSelectorPrefix:fromClass:

- (void)addAllScenariosWithSelectorPrefix:(NSString *)selectorPrefix fromClass:(Class)klass
Discussion

@method addScenariosWithSelectorPrefix:fromClass:

This enumerates the list of class methods on the given class and adds those starting with the given prefix alphabetically.

Parameters

selectorPrefix

Added selectors must have this prefix.

klass

The class to search for scenarios.

Declared In

KIFTestController.h

addScenario:

- (void)addScenario:(KIFTestScenario *)scenario
Discussion

@method addScenario:

Scenarios will be run in the order that they’re added.

Parameters

scenario

The scenario to add to the test suite.

Declared In

KIFTestController.h

initializeScenarios

- (void)initializeScenarios
Discussion

@method initializeScenarios

The default implementation of this method does nothing. Subclasses should override it so that it configures the scenarios for the test controller to run. This method is invoked automatically and should never need to be invoked manually.

Declared In

KIFTestController.h

startTestingWithCompletionBlock:

- (void)startTestingWithCompletionBlock:(KIFTestControllerCompletionBlock)completionBlock
Discussion

@method startTestingWithCompletionBlock:

Testing is done asynchronously by inserting itself into the run loop at appropriate times. As such, this method will not block. To be notified when testing is complete, implement the completionBlock.

Parameters

completionBlock

An optional execution block that will be invoked when testing is complete.

Declared In

KIFTestController.h