222
|
1 |
"{ Package: 'stx:goodies/sunit' }"
|
|
2 |
|
|
3 |
SimpleTestResourceTestCase subclass:#ManyTestResourceTestCase
|
|
4 |
instanceVariableNames:''
|
|
5 |
classVariableNames:''
|
|
6 |
poolDictionaries:''
|
|
7 |
category:'SUnit-Tests'
|
|
8 |
!
|
|
9 |
|
|
10 |
|
|
11 |
!ManyTestResourceTestCase class methodsFor:'accessing'!
|
|
12 |
|
|
13 |
resources
|
|
14 |
^super resources, (Array with: SimpleTestResourceA with: SimpleTestResourceB)
|
|
15 |
! !
|
|
16 |
|
|
17 |
!ManyTestResourceTestCase class methodsFor:'testing'!
|
|
18 |
|
|
19 |
shouldInheritSelectors
|
|
20 |
^true
|
|
21 |
! !
|
|
22 |
|
|
23 |
!ManyTestResourceTestCase methodsFor:'running'!
|
|
24 |
|
|
25 |
testTearDownOrder
|
|
26 |
| myResourceSetUpOrder myResourceReverseTearDownOrder |
|
|
27 |
myResourceReverseTearDownOrder := OrderedCollection new: 7.
|
|
28 |
myResourceSetUpOrder := (OrderedCollection new: 7)
|
|
29 |
add: SimpleTestResource;
|
|
30 |
add: SimpleTestResourceA1;
|
|
31 |
add: SimpleTestResourceA2;
|
|
32 |
add: SimpleTestResourceA;
|
|
33 |
add: SimpleTestResourceB1;
|
|
34 |
add: SimpleTestResourceB;
|
|
35 |
yourself.
|
|
36 |
self assert: (myResourceSetUpOrder allSatisfy: [:each | each isAvailable])
|
|
37 |
description: 'At test start, not all my resources were set up'.
|
|
38 |
self class resources do:
|
|
39 |
[:each | each resetOrAddResourcesTo: myResourceReverseTearDownOrder].
|
|
40 |
self assert: myResourceReverseTearDownOrder = myResourceSetUpOrder
|
|
41 |
description: 'Wrong order for tearDown'.
|
|
42 |
self assert: (myResourceSetUpOrder allSatisfy: [:each | each isAvailable])
|
|
43 |
description: 'At test start, not all my resources were set up'.
|
|
44 |
! !
|
|
45 |
|
|
46 |
!ManyTestResourceTestCase methodsFor:'utility'!
|
|
47 |
|
|
48 |
clearOuterResourceStateDuring: aBlock
|
|
49 |
"This self-testing test must clear the outer state of its resources before starting and after finishing, so that it can construct test cases and suites of itself and test them."
|
|
50 |
|
|
51 |
self assert: SimpleTestResourceA1 isAlreadyAvailable
|
|
52 |
description: 'The resource was not set up for the test'.
|
|
53 |
SimpleTestResourceA reset.
|
|
54 |
SimpleTestResourceB reset.
|
|
55 |
SimpleTestResourceA1 reset.
|
|
56 |
self deny: SimpleTestResourceA1 isAlreadyAvailable
|
|
57 |
description: 'The resource was still set up before we began the run'.
|
|
58 |
^[super clearOuterResourceStateDuring: aBlock] sunitEnsure:
|
|
59 |
[self deny: SimpleTestResourceA1 isAlreadyAvailable
|
|
60 |
description: 'The resource was still set up after we finished the run'.
|
|
61 |
self deny: SimpleTestResourceB1 isAlreadyAvailable
|
|
62 |
description: 'The resource was still set up after we finished the run'.
|
|
63 |
SimpleTestResourceA isAvailable.
|
|
64 |
self assert: SimpleTestResourceA1 isAlreadyAvailable
|
|
65 |
description: 'The resource was not set up again after the test'.
|
|
66 |
SimpleTestResourceB isAvailable.
|
|
67 |
self assert: SimpleTestResourceB1 isAlreadyAvailable
|
|
68 |
description: 'The resource was not set up again after the test'.].
|
|
69 |
|
|
70 |
"Modified: / 11-09-2010 / 16:44:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
71 |
! !
|
|
72 |
|
|
73 |
!ManyTestResourceTestCase class methodsFor:'documentation'!
|
|
74 |
|
|
75 |
version_SVN
|
|
76 |
^ '§Id: ManyTestResourceTestCase.st 214 2011-03-14 12:22:21Z vranyj1 §'
|
|
77 |
! !
|