- Inherits From:
- SenTest
- Conforms To:
- NSCoding
- Declared In:
- SenTestCase.h
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
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.
NSInvocation *invocation;
SenTestCaseRun *run;
SEL failureAction;
invocation No description. run No description. failureAction No description.
Creating test casesSetting and returning invocation and selector
- + testCaseWithInvocation:
- - initWithInvocation:
- + testCaseWithSelector:
- - initWithSelector:
Setting test case behavior after a failure
- - setInvocation:
- - invocation
- - selector
Failing a test, used by all macros
- - continueAfterFailure
- - raiseAfterFailure
Returning the class' test methods
- - failWithException:
- + testInvocations
+ (id)testCaseWithInvocation:(NSInvocation *)anInvocation
No method description.
+ (id)testCaseWithSelector:(SEL)aSelector
No method description.
+ (id)testInvocations
No method description.
- (void)continueAfterFailure
No method description.
- (void)failWithException:(NSException *)anException
No method description.
- (id)initWithInvocation:(NSInvocation *)anInvocation
No method description.
- (id)initWithSelector:(SEL)aSelector
No method description.
- (NSInvocation *)invocation
No method description.
- (void)raiseAfterFailure
No method description.
- (SEL)selector
No method description.
- (void)setInvocation:(NSInvocation *)anInvocation
No method description.