Documentation

UKTestHandler class documentation

UKTestHandler : NSObject

UKTestHandler implements the test assertions built into UnitKit and track the test results

AuthorsGenerated by builder
Declared inUKTestHandler.h

Overview

For each test assertion invoked on the test handler, the handler collects the result and reports it or not based on the reporting settings.

At any time, you can query the current test results using -testsPassed , -testsFailed and -exceptionsReported , for all the test assertions invoked since the test handler has been created.

A single test handler exists for all UKRunner instances. For multiple run test requests against UKRunner instances, all test results are reported together.


Initialization

+ (UKTestHandler *) handler

Returns the shared test handler.

    Controlling Test Result Reporting

    - (id) delegate

    Returns a delegate that can implement the same reporting methods than UKTestHandler.

    By default, returns nil.

    For more details, see -setDelegate: .

      - (void) setDelegate: (id)aDelegate

      Sets a delegate that can implement the same reporting methods than UKTestHandler.

      If the delegate implements a reporting method, it takes priority over UKTestHandler. As a result, what was previously reported by UKTestHandler is not going to be automatically logged in the console unless the delegate does it.

        - (BOOL) isQuiet

        Returns whether the handler should report just the test failures and uncaught exceptions, but nothing on test successes.

        By default, returns NO.

        -isQuiet is initialized to YES if the argument -q is present in the ukrun arguments.

          - (void) setQuiet: (BOOL)isQuiet

          Tells the handler to report just the test failures and uncaught exceptions, but nothing on test successes.

            - (void) reportStatus: (BOOL)cond inFile: (const char*)filename line: (int)line message: (NSString *)msg

            If we have a delegate, then by all means use it. If we don't, then check to see if we have any errors which should be reported off to std out.

              - (void) reportException: (NSException *)exception inClass: (Class)testClass hint: (NSString *)hint

              Reports an uncaught exception and a hint that represents the context in which the exception was raised.

              To indicate the context, three hints are supported:

              errExceptionOnInit
              inside -init on a test object
              errExceptionOnRelease
              inside -dealloc on a test object
              a test method name
              inside a test method

              By default, forwards the message to the delegate if there is one, otherwise uses -reportWarning: to print the exception reason.

                - (void) reportWarning: (NSString *)message

                Reports a warning message.

                By default, forwards the message to the delegate if there is one, otherwise uses NSLog() to print the message.

                This method is used by -reportStatus:inFile:line:message: and -reportException:inClass:hint: to report test failures and uncaught exceptions.

                  Test Results

                  - (int) testsPassed

                  Returns the current number of test successes.

                  See -reportStatus:inFile:line:message:.

                    - (int) testsFailed

                    Returns the current number of test failures.

                    See -reportStatus:inFile:line:message:.

                      - (int) exceptionsReported

                      Returns the current number of exceptions caught by UKRunner and reported to the test handler.

                      See -reportException:inClass:hint: .

                        Basic Test Assertions

                        - (void) passInFile: (const char*)filename line: (int)line
                        Description forthcoming.
                          - (void) failInFile: (const char*)filename line: (int)line
                          Description forthcoming.

                            Primitive Test Assertions

                            - (void) testTrue: (BOOL)cond inFile: (const char*)filename line: (int)line
                            Description forthcoming.
                              - (void) testFalse: (BOOL)cond inFile: (const char*)filename line: (int)line
                              Description forthcoming.
                                - (void) testNil: (void*)ref inFile: (const char*)filename line: (int)line
                                Description forthcoming.
                                  - (void) testNotNil: (void*)ref inFile: (const char*)filename line: (int)line
                                  Description forthcoming.

                                    Number Primitive Test Assertions

                                    - (void) testInt: (int)a equalTo: (int)b inFile: (const char*)filename line: (int)line
                                    Description forthcoming.
                                      - (void) testInt: (int)a notEqualTo: (int)b inFile: (const char*)filename line: (int)line
                                      Description forthcoming.
                                        - (void) testFloat: (float)a equalTo: (float)b delta: (float)delta inFile: (const char*)filename line: (int)line
                                        Description forthcoming.
                                          - (void) testFloat: (float)a notEqualTo: (float)b delta: (float)delta inFile: (const char*)filename line: (int)line
                                          Description forthcoming.

                                            Object Test Assertions

                                            - (void) testObject: (id)a kindOf: (id)b inFile: (const char*)filename line: (int)line
                                            Description forthcoming.
                                              - (void) testObject: (id)a equalTo: (id)b inFile: (const char*)filename line: (int)line
                                              Description forthcoming.
                                                - (void) testObject: (id)a notEqualTo: (id)b inFile: (const char*)filename line: (int)line
                                                Description forthcoming.
                                                  - (void) testObject: (id)a sameAs: (id)b inFile: (const char*)filename line: (int)line
                                                  Description forthcoming.
                                                    - (void) testObject: (id)a notSameAs: (id)b inFile: (const char*)filename line: (int)line
                                                    Description forthcoming.

                                                      String Test Assertions

                                                      - (void) testString: (NSString *)a equalTo: (NSString *)b inFile: (const char*)filename line: (int)line
                                                      Description forthcoming.
                                                        - (void) testString: (NSString *)a notEqualTo: (NSString *)b inFile: (const char*)filename line: (int)line
                                                        Description forthcoming.
                                                          - (void) testString: (NSString *)a contains: (NSString *)b inFile: (const char*)filename line: (int)line
                                                          Description forthcoming.
                                                            - (void) testString: (NSString *)a doesNotContain: (NSString *)b inFile: (const char*)filename line: (int)line
                                                            Description forthcoming.

                                                              Exception Test Assertions

                                                              - (void) raisesException: (NSException *)exception inFile: (const char*)filename line: (int)line
                                                              Description forthcoming.
                                                                - (void) doesNotRaisesException: (NSException *)exception inFile: (const char*)filename line: (int)line
                                                                Description forthcoming.
                                                                  - (void) raisesException: (NSException *)exception named: (NSString *)expected inFile: (const char*)filename line: (int)line
                                                                  Description forthcoming.
                                                                    - (void) raisesException: (id)raisedObject class: (Class)expectedClass inFile: (const char*)filename line: (int)line
                                                                    Description forthcoming.