Inherits from NSObject
Declared in GHTestCase.h
GHTestCase.m

Overview

The base class for a test case.

 @interface MyTest : GHTestCase {}
 @end

 @implementation MyTest

 // Run before each test method
 - (void)setUp { }

 // Run after each test method
 - (void)tearDown { }

 // Run before the tests are run for this class
 - (void)setUpClass { }

 // Run before the tests are run for this class
 - (void)tearDownClass { }

 // Tests are prefixed by 'test' and contain no arguments and no return value
 - (void)testA { 
   GHTestLog(@"Log with a test with the GHTestLog(...) for test specific logging.");
 }

 // Another test; Tests are run in lexical order
 - (void)testB { }

 // Override any exceptions; By default exceptions are raised, causing a test failure
 - (void)failWithException:(NSException *)exception { }

 @end

Tasks

  • – failWithException:

    By default exceptions are raised, causing a test failure

  • – setUpClass

    Run before the tests (once per test case).

  • – tearDownClass

    Run after the tests (once per test case).

  • – shouldRunOnMainThread

    Whether to run the tests on a separate thread. Override this method in your test case to override the default. Default is NO, tests are run on a separate thread by default.

  • – handleException:

    Any special handling of exceptions after they are thrown; By default logs stack trace to standard out.

  • – log:

    Log a message, which notifies the log delegate. This is not meant to be used directly, see GHTestLog(…) macro.

  • – isCLIDisabled

    Whether the test class should be run as a part of command line tests. By default this is NO. Subclasses can override this method to disable test classes that are problematic at the command line.

Instance Methods

failWithException:

By default exceptions are raised, causing a test failure

- (void)failWithException:(NSException *)exception

Parameters

exception

Exception that was raised by test

Declared In

GHTestCase.h

handleException:

Any special handling of exceptions after they are thrown; By default logs stack trace to standard out.

- (void)handleException:(NSException *)exception

Parameters

exception

Exception

Declared In

GHTestCase.h

isCLIDisabled

Whether the test class should be run as a part of command line tests. By default this is NO. Subclasses can override this method to disable test classes that are problematic at the command line.

- (BOOL)isCLIDisabled

Return Value

YES if this test class is disabled for command line tests

Declared In

GHTestCase.h

log:

Log a message, which notifies the log delegate. This is not meant to be used directly, see GHTestLog(…) macro.

- (void)log:(NSString *)message

Parameters

message

Message to log

Declared In

GHTestCase.h

setUpClass

Run before the tests (once per test case).

- (void)setUpClass

Declared In

GHTestCase.h

shouldRunOnMainThread

Whether to run the tests on a separate thread. Override this method in your test case to override the default. Default is NO, tests are run on a separate thread by default.

- (BOOL)shouldRunOnMainThread

Return Value

If YES, the test will run on the main thread

Declared In

GHTestCase.h

tearDownClass

Run after the tests (once per test case).

- (void)tearDownClass

Declared In

GHTestCase.h