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 STAssertTrue() macro 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
    {    
        STAssertTrue (f1 + f2 == 5.0, @"f + f should equal 5.0", f1, f2);
    }
    @end
    


Macro Definitions

Synopsis:

STAssertNotNil(a1, description, ...)
STAssertTrue(expression, description, ...)
STAssertFalse(expression, description, ...)
STAssertEqualObjects(a1, a2, description, ...)
STAssertEquals(a1, a2, description, ...)
STAssertEqualsWithAccuracy(left, right, accuracy, description, ...)
STAssertThrows(expression, description, ...)
STAssertThrowsSpecific(expression, specificException, description, ...)
STAssertThrowsSpecificNamed(expr, specificException, aName, description, ...)
STAssertNoThrow(expression, description, ...)
STAssertNoThrowSpecific(expression, specificException, description, ...)
STAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...)
STFail(description, ...)
STAssertTrueNoThrow(expression, description, ...)
STAssertFalseNoThrow(expression, description, ...)

Synopsis:

should(expression)
should1(expression,description)
shouldnt(expression)
shouldnt1(expression,description)
shouldBeEqual(left,right)
shouldBeEqual1(left,right,description)
shouldRaise(expression)
shouldRaise1(expression,description)
shouldntRaise(expression)
shouldntRaise1(expression,description)
fail()
fail1(description)
shouldnoraise(expression)
should1noraise(expression,description)
shouldntnoraise(expression)
shouldnt1noraise(expression,description)

Description:

These marcos are deprecated


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

+ (NSArray *)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.


CVS Version 1.24 Copyright ©2005 by Sente SA. All Rights Reserved. Fri Apr 01 13:49:06 2005