-
Notifications
You must be signed in to change notification settings - Fork 1
/
SenTestCase.h
165 lines (131 loc) · 5.32 KB
/
SenTestCase.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/*$Id: SenTestCase.h,v 1.26 2005/04/02 03:18:20 phink Exp $*/
// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved.
//
// Use of this source code is governed by the following license:
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// (1) Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// (2) Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Note: this license is equivalent to the FreeBSD license.
//
// This notice may not be removed from this file.
#import <Foundation/NSObject.h>
#import "SenTest.h"
#define STAssertNotNil(a1, description, ...)
#define STAssertTrue(expression, description, ...)
#define STAssertFalse(expression, description, ...)
#define STAssertEqualObjects(a1, a2, description, ...)
#define STAssertEquals(a1, a2, description, ...)
#define STAssertEqualsWithAccuracy(left, right, accuracy, description, ...)
#define STAssertThrows(expression, description, ...)
#define STAssertThrowsSpecific(expression, specificException, description, ...)
#define STAssertThrowsSpecificNamed(expr, specificException, aName, description, ...)
#define STAssertNoThrow(expression, description, ...)
#define STAssertNoThrowSpecific(expression, specificException, description, ...)
#define STAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...)
#define STFail(description, ...)
#define STAssertTrueNoThrow(expression, description, ...)
#define STAssertFalseNoThrow(expression, description, ...)
/*" These marcos are deprecated "*/
#define should(expression)
#define should1(expression,description)
#define shouldnt(expression)
#define shouldnt1(expression,description)
#define shouldBeEqual(left,right)
#define shouldBeEqual1(left,right,description)
#define shouldRaise(expression)
#define shouldRaise1(expression,description)
#define shouldntRaise(expression)
#define shouldntRaise1(expression,description)
#define fail()
#define fail1(description)
#define shouldnoraise(expression)
#define should1noraise(expression,description)
#define shouldntnoraise(expression)
#define shouldnt1noraise(expression,description)
#import "SenTestCase_Macros.h"
#import "NSException_SenTestFailure.h"
/*"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
}
"*/
@class SenTestSuite;
@class SenTestCaseRun;
@interface SenTestCase : SenTest <NSCoding>
{
@private
NSInvocation *invocation;
SenTestCaseRun *run;
SEL failureAction;
}
/*"Creating test cases"*/
+ (id) testCaseWithInvocation:(NSInvocation *) anInvocation;
- (id) initWithInvocation:(NSInvocation *) anInvocation;
+ (id) testCaseWithSelector:(SEL) aSelector;
- (id) initWithSelector:(SEL) aSelector;
/*"Setting and returning invocation and selector"*/
- (void) setInvocation:(NSInvocation *) anInvocation;
- (NSInvocation *) invocation;
- (SEL) selector;
/*"Setting test case behavior after a failure"*/
- (void) continueAfterFailure;
- (void) raiseAfterFailure;
/*"Failing a test, used by all macros"*/
- (void) failWithException:(NSException *) anException;
/*"Returning the class' test methods"*/
+ (NSArray *) testInvocations;
@end
@interface SenTestCase (Suite)
/*"Returning a test suite with all the test cases"*/
+ (id) defaultTestSuite;
@end
@interface SenTestCase (_Protected)
- (SEL) failureAction;
- (void) setFailureAction:(SEL) aSelector;
@end