185
|
1 |
"{ Package: 'stx:goodies/sunit' }"
|
|
2 |
|
637
|
3 |
"{ NameSpace: Smalltalk }"
|
|
4 |
|
185
|
5 |
TestCase subclass:#TestCaseWithArguments
|
|
6 |
instanceVariableNames:'testArguments'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SUnit-Base'
|
|
10 |
!
|
|
11 |
|
|
12 |
!TestCaseWithArguments class methodsFor:'documentation'!
|
|
13 |
|
|
14 |
documentation
|
|
15 |
"
|
|
16 |
allows for an argument to be passed to the testCase-method.
|
|
17 |
|
|
18 |
To do so, redefine buildAdditionalTestsInSuite:suite,
|
|
19 |
to add more tests by sending
|
269
|
20 |
addTest:(self testSelector: testArguments )
|
185
|
21 |
|
269
|
22 |
Useful for example, if you want to evaluate a suite's-test method on each file in some directory,
|
185
|
23 |
but still want to see the results as individual runs (to allow for a rerun-defects)
|
|
24 |
|
|
25 |
[author:]
|
269
|
26 |
cg@exept.de
|
185
|
27 |
"
|
|
28 |
! !
|
|
29 |
|
|
30 |
!TestCaseWithArguments class methodsFor:'instance creation'!
|
|
31 |
|
|
32 |
selector: aSymbol argument: arg
|
222
|
33 |
^self new
|
|
34 |
setTestSelector: aSymbol
|
|
35 |
setTestArguments: (Array with:arg)
|
185
|
36 |
!
|
|
37 |
|
|
38 |
selector: aSymbol arguments: args
|
222
|
39 |
^self new
|
|
40 |
setTestSelector: aSymbol
|
|
41 |
setTestArguments: args
|
185
|
42 |
! !
|
|
43 |
|
|
44 |
!TestCaseWithArguments class methodsFor:'building suites'!
|
|
45 |
|
|
46 |
buildAdditionalTestsInSuite:suite
|
|
47 |
self subclassResponsibility
|
|
48 |
!
|
|
49 |
|
|
50 |
buildSuite
|
|
51 |
|suite|
|
|
52 |
|
|
53 |
suite := super buildSuite.
|
|
54 |
self buildAdditionalTestsInSuite:suite.
|
|
55 |
^ suite
|
|
56 |
! !
|
|
57 |
|
637
|
58 |
!TestCaseWithArguments class methodsFor:'queries'!
|
204
|
59 |
|
|
60 |
isAbstract
|
|
61 |
"Override to true if a TestCase subclass is Abstract and should not have
|
|
62 |
TestCase instances built from it"
|
|
63 |
|
|
64 |
^ self == TestCaseWithArguments
|
|
65 |
! !
|
|
66 |
|
185
|
67 |
!TestCaseWithArguments methodsFor:'printing'!
|
|
68 |
|
222
|
69 |
getTestName
|
|
70 |
testArguments isEmptyOrNil ifTrue:[^testSelector].
|
|
71 |
^testSelector , '(' , testArguments first printString , ')'.
|
195
|
72 |
!
|
|
73 |
|
222
|
74 |
printOn: aStream
|
|
75 |
aStream nextPutAll: self name.
|
|
76 |
aStream nextPutAll: '>>'.
|
|
77 |
testSelector printOn: aStream.
|
|
78 |
testSelector numArgs > 0 ifTrue:[
|
|
79 |
aStream nextPutAll: ' ('.
|
|
80 |
testArguments printOn: aStream.
|
|
81 |
aStream nextPutAll: ')'.
|
|
82 |
].
|
185
|
83 |
! !
|
|
84 |
|
|
85 |
!TestCaseWithArguments methodsFor:'private'!
|
|
86 |
|
|
87 |
performTest
|
329
|
88 |
self perform:(testSelector asSymbol) withArguments:(testArguments)
|
185
|
89 |
!
|
|
90 |
|
|
91 |
setTestSelector:aSymbol setTestArguments: args
|
222
|
92 |
testSelector := aSymbol.
|
185
|
93 |
testArguments := args
|
|
94 |
! !
|
|
95 |
|
|
96 |
!TestCaseWithArguments class methodsFor:'documentation'!
|
|
97 |
|
|
98 |
version
|
637
|
99 |
^ '$Header$'
|
204
|
100 |
!
|
|
101 |
|
|
102 |
version_CVS
|
637
|
103 |
^ '$Header$'
|
222
|
104 |
!
|
|
105 |
|
|
106 |
version_SVN
|
637
|
107 |
^ '$Id$'
|
185
|
108 |
! !
|
637
|
109 |
|