SenTestCase


Inherits From:
SenTest
Conforms To:
NSCoding
Declared In:
SenTestCase.h


Class Description

A test case defines the fixture to run multiple tests. To define a test case:

1) create a subclass of SenTestCase

2) implement test methods

3) optionally define instance variables that store the state of the fixture

4) optionally initialize the fixture state by overriding setUp

5) optionally clean-up after a test by overriding tearDown.

Test methods with no parameters, returning no value, and prefixed with 'test', such as:     
    - (void) testSomething;
    

are automatically recognized as test cases by the SenTestingKit framework. Each SenTestCase subclass' defaultTestSuite is a SenTestSuite which includes theses tests.

Test methods implementations usually contains assertions that must be verified for the test to pass: the should() macros defined below. Here is an example:

    
    @interface MathTest : SenTestCase
    {    
        float f1;
        float f2;
    }
    - (void) testAddition;
    @end
    
    @implementation MathTest
    - (void) setUp
    {    
        f1 = 2.0;
        f2 = 3.0;
    }
    
    - (void) testAddition
    {    
        should (f1 + f2 == 5.0);
    }
    @end
    


Macro Definitions

Synopsis:

should(condition)
should1(condition,description)

Description:

Generate a failure when condition evaluates to true.

Synopsis:

shouldnt(condition)
shouldnt1(condition,description)

Description:

Generate a failure when a condition evaluates to false.

Synopsis:

shouldBeEqual(left,right)
shouldBeEqual1(left,right,description)

Description:

Generate a failure when [left isEqualTo:right] is false (or left is nil and right is not).

Synopsis:

shouldRaise(expression)
shouldRaise1(expression,description)

Description:

Generate a failure when expression does not raise an exception.

Synopsis:

shouldntRaise(expression)
shouldntRaise1(expression,description)

Description:

Generate a failure when expression does raise an exception.

Synopsis:

fail()
fail1(description)

Description:

Generate a failure inconditionally.


Instance Variables

NSInvocation *invocation;
SenTestCaseRun *run;
SEL failureAction;

invocationNo description.
runNo description.
failureActionNo description.


Method Types

Creating test cases
+ testCaseWithInvocation:
- initWithInvocation:
+ testCaseWithSelector:
- initWithSelector:
Setting and returning invocation and selector
- setInvocation:
- invocation
- selector
Setting test case behavior after a failure
- continueAfterFailure
- raiseAfterFailure
Failing a test, used by all macros
- failWithException:
Returning the class' test methods
+ testInvocations


Class Methods

testCaseWithInvocation:

+ (id)testCaseWithInvocation:(NSInvocation *)anInvocation

No method description.


testCaseWithSelector:

+ (id)testCaseWithSelector:(SEL)aSelector

No method description.


testInvocations

+ (id)testInvocations

No method description.


Instance Methods

continueAfterFailure

- (void)continueAfterFailure

No method description.


failWithException:

- (void)failWithException:(NSException *)anException

No method description.


initWithInvocation:

- (id)initWithInvocation:(NSInvocation *)anInvocation

No method description.


initWithSelector:

- (id)initWithSelector:(SEL)aSelector

No method description.


invocation

- (NSInvocation *)invocation

No method description.


raiseAfterFailure

- (void)raiseAfterFailure

No method description.


selector

- (SEL)selector

No method description.


setInvocation:

- (void)setInvocation:(NSInvocation *)anInvocation

No method description.


Version 1.8 Copyright ©2001 by Sen:te (Sente SA). All Rights Reserved.