Skip to content

Commit 044fb70

Browse files
authored
Merge pull request #82 from DurieuxPol/feat/moreTestFilters
New test filters
2 parents ad184af + 4bc106f commit 044fb70

12 files changed

+325
-17
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Class {
2+
#name : 'MTBlockTestFilter',
3+
#superclass : 'MTTestFilter',
4+
#category : 'MuTalk-Model-Test filters',
5+
#package : 'MuTalk-Model',
6+
#tag : 'Test filters'
7+
}
8+
9+
{ #category : 'enumerating' }
10+
MTBlockTestFilter >> filterTests: aTestCaseCollection [
11+
12+
^ aTestCaseCollection select: condition
13+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Class {
2+
#name : 'MTPragmaRejectionTestFilter',
3+
#superclass : 'MTPragmaTestFilter',
4+
#category : 'MuTalk-Model-Test filters',
5+
#package : 'MuTalk-Model',
6+
#tag : 'Test filters'
7+
}
8+
9+
{ #category : 'enumerating' }
10+
MTPragmaRejectionTestFilter >> filterTests: aTestCaseCollection [
11+
12+
^ aTestCaseCollection reject: [ :testCaseReference |
13+
self isPragmaValidFrom: testCaseReference ]
14+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Class {
2+
#name : 'MTPragmaSelectionTestFilter',
3+
#superclass : 'MTPragmaTestFilter',
4+
#category : 'MuTalk-Model-Test filters',
5+
#package : 'MuTalk-Model',
6+
#tag : 'Test filters'
7+
}
8+
9+
{ #category : 'enumerating' }
10+
MTPragmaSelectionTestFilter >> filterTests: aTestCaseCollection [
11+
12+
^ aTestCaseCollection select: [ :testCaseReference |
13+
self isPragmaValidFrom: testCaseReference ]
14+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Class {
2+
#name : 'MTPragmaTestFilter',
3+
#superclass : 'MTTestFilter',
4+
#instVars : [
5+
'pragmaArguments'
6+
],
7+
#category : 'MuTalk-Model-Test filters',
8+
#package : 'MuTalk-Model',
9+
#tag : 'Test filters'
10+
}
11+
12+
{ #category : 'instance creation' }
13+
MTPragmaTestFilter class >> for: aPragmaSelector [
14+
15+
^ self for: aPragmaSelector arguments: #( )
16+
]
17+
18+
{ #category : 'instance creation' }
19+
MTPragmaTestFilter class >> for: aPragmaSelector arguments: pragmaArguments [
20+
21+
^ self new
22+
condition: aPragmaSelector;
23+
pragmaArguments: pragmaArguments;
24+
yourself
25+
]
26+
27+
{ #category : 'testing' }
28+
MTPragmaTestFilter class >> isAbstract [
29+
30+
^ self == MTPragmaTestFilter
31+
]
32+
33+
{ #category : 'enumerating' }
34+
MTPragmaTestFilter >> filterTests: aTestCaseCollection [
35+
36+
^ self subclassResponsibility
37+
]
38+
39+
{ #category : 'testing' }
40+
MTPragmaTestFilter >> isPragmaValidFrom: aTestCaseReference [
41+
42+
| pragmas |
43+
pragmas := aTestCaseReference method pragmas.
44+
^ pragmas anySatisfy: [ :pragma |
45+
pragma selector = condition & (pragma arguments = pragmaArguments) ]
46+
]
47+
48+
{ #category : 'accessing' }
49+
MTPragmaTestFilter >> pragmaArguments [
50+
51+
^ pragmaArguments
52+
]
53+
54+
{ #category : 'accessing' }
55+
MTPragmaTestFilter >> pragmaArguments: anObject [
56+
57+
pragmaArguments := anObject
58+
]
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Class {
2-
#name : 'MTAuxiliarClassForTimeTestFilter',
2+
#name : 'MTAuxiliarClassForTestFilter',
33
#superclass : 'Object',
44
#category : 'MuTalk-TestResources',
55
#package : 'MuTalk-TestResources'
66
}
77

88
{ #category : 'accessing' }
9-
MTAuxiliarClassForTimeTestFilter >> simpleMethod [
9+
MTAuxiliarClassForTestFilter >> simpleMethod [
1010

1111
^ 1 + 1
1212
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Class {
2+
#name : 'MTAuxiliarTestClassForBlockTestFilter',
3+
#superclass : 'TestCase',
4+
#category : 'MuTalk-TestResources',
5+
#package : 'MuTalk-TestResources'
6+
}
7+
8+
{ #category : 'tests' }
9+
MTAuxiliarTestClassForBlockTestFilter >> testX [
10+
11+
self assert: true
12+
]
13+
14+
{ #category : 'tests' }
15+
MTAuxiliarTestClassForBlockTestFilter >> testY [
16+
17+
self assert: true
18+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Class {
2+
#name : 'MTAuxiliarTestClassForPragmaTestFilter',
3+
#superclass : 'TestCase',
4+
#category : 'MuTalk-TestResources',
5+
#package : 'MuTalk-TestResources'
6+
}
7+
8+
{ #category : 'tests' }
9+
MTAuxiliarTestClassForPragmaTestFilter >> testWithPragma [
10+
11+
<aPragma>
12+
self assert: true
13+
]
14+
15+
{ #category : 'tests' }
16+
MTAuxiliarTestClassForPragmaTestFilter >> testWithoutPragma [
17+
18+
self assert: true
19+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
Class {
2+
#name : 'MTBlockTestFilterTest',
3+
#superclass : 'MTTestFilterTest',
4+
#category : 'MuTalk-Tests',
5+
#package : 'MuTalk-Tests'
6+
}
7+
8+
{ #category : 'running' }
9+
MTBlockTestFilterTest >> runAnalysisForBlockCondition: aBlock [
10+
11+
self
12+
runAnalysisWithFilter: (MTBlockTestFilter for: aBlock)
13+
on: { MTAuxiliarClassForTestFilter }
14+
withTests: { MTAuxiliarTestClassForBlockTestFilter }
15+
]
16+
17+
{ #category : 'tests' }
18+
MTBlockTestFilterTest >> testAllTestsAreExcluded [
19+
20+
self runAnalysisForBlockCondition: [ :testCase |
21+
testCase selector beginsWith: 'testZ' ].
22+
23+
self
24+
assert: (analysis generalResult particularResults at: 1) runCount
25+
equals: 0
26+
]
27+
28+
{ #category : 'tests' }
29+
MTBlockTestFilterTest >> testYTestIsExcluded [
30+
31+
| result |
32+
self runAnalysisForBlockCondition: [ :testCase |
33+
testCase selector beginsWith: 'testX' ].
34+
result := analysis generalResult particularResults at: 1.
35+
36+
self assert: result runCount equals: 1.
37+
self assert: (result mutantResults at: 1) selector equals: #testX
38+
]
39+
40+
{ #category : 'tests' }
41+
MTBlockTestFilterTest >> testYTestIsNotExcluded [
42+
43+
self runAnalysisForBlockCondition: [ :testCase |
44+
testCase selector beginsWith: 'test' ].
45+
46+
self
47+
assert: (analysis generalResult particularResults at: 1) runCount
48+
equals: 2
49+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Class {
2+
#name : 'MTPragmaRejectionTestFilterTest',
3+
#superclass : 'MTTestFilterTest',
4+
#category : 'MuTalk-Tests',
5+
#package : 'MuTalk-Tests'
6+
}
7+
8+
{ #category : 'running' }
9+
MTPragmaRejectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelector [
10+
11+
self
12+
runAnalysisWithFilter:
13+
(MTPragmaRejectionTestFilter for: aPragmaSelector)
14+
on: { MTAuxiliarClassForTestFilter }
15+
withTests: { MTAuxiliarTestClassForPragmaTestFilter }
16+
]
17+
18+
{ #category : 'running' }
19+
MTPragmaRejectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelector andArguments: pragmaArguments [
20+
21+
self
22+
runAnalysisWithFilter: (MTPragmaRejectionTestFilter
23+
for: aPragmaSelector
24+
arguments: pragmaArguments)
25+
on: { MTAuxiliarClassForTestFilter }
26+
withTests: { MTAuxiliarTestClassForPragmaTestFilter }
27+
]
28+
29+
{ #category : 'tests' }
30+
MTPragmaRejectionTestFilterTest >> testTestWithPragmaIsExcluded [
31+
32+
| result |
33+
self runAnalysisForPragmaCondition: #aPragma.
34+
result := analysis generalResult particularResults at: 1.
35+
36+
self assert: result runCount equals: 1.
37+
self
38+
assert: (result mutantResults at: 1) selector
39+
equals: #testWithoutPragma
40+
]
41+
42+
{ #category : 'tests' }
43+
MTPragmaRejectionTestFilterTest >> testTestWithPragmaIsNotExcluded [
44+
45+
self runAnalysisForPragmaCondition: #anotherPragma.
46+
47+
self
48+
assert: (analysis generalResult particularResults at: 1) runCount
49+
equals: 2
50+
]
51+
52+
{ #category : 'tests' }
53+
MTPragmaRejectionTestFilterTest >> testTestWithPragmaIsNotExcluded2 [
54+
55+
self runAnalysisForPragmaCondition: #aPragma: andArguments: 'arg'.
56+
57+
self
58+
assert: (analysis generalResult particularResults at: 1) runCount
59+
equals: 2
60+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Class {
2+
#name : 'MTPragmaSelectionTestFilterTest',
3+
#superclass : 'MTTestFilterTest',
4+
#category : 'MuTalk-Tests',
5+
#package : 'MuTalk-Tests'
6+
}
7+
8+
{ #category : 'running' }
9+
MTPragmaSelectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelector [
10+
11+
self
12+
runAnalysisWithFilter:
13+
(MTPragmaSelectionTestFilter for: aPragmaSelector)
14+
on: { MTAuxiliarClassForTestFilter }
15+
withTests: { MTAuxiliarTestClassForPragmaTestFilter }
16+
]
17+
18+
{ #category : 'running' }
19+
MTPragmaSelectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelector andArguments: pragmaArguments [
20+
21+
self
22+
runAnalysisWithFilter: (MTPragmaSelectionTestFilter
23+
for: aPragmaSelector
24+
arguments: pragmaArguments)
25+
on: { MTAuxiliarClassForTestFilter }
26+
withTests: { MTAuxiliarTestClassForPragmaTestFilter }
27+
]
28+
29+
{ #category : 'tests' }
30+
MTPragmaSelectionTestFilterTest >> testAllTestsAreExcluded [
31+
32+
self runAnalysisForPragmaCondition: #anotherPragma.
33+
34+
self
35+
assert: (analysis generalResult particularResults at: 1) runCount
36+
equals: 0
37+
]
38+
39+
{ #category : 'tests' }
40+
MTPragmaSelectionTestFilterTest >> testAllTestsAreExcluded2 [
41+
42+
self runAnalysisForPragmaCondition: #aPragma: andArguments: 'arg'.
43+
44+
self
45+
assert: (analysis generalResult particularResults at: 1) runCount
46+
equals: 0
47+
]
48+
49+
{ #category : 'tests' }
50+
MTPragmaSelectionTestFilterTest >> testTestWithoutPragmaIsExcluded [
51+
52+
| result |
53+
self runAnalysisForPragmaCondition: #aPragma.
54+
result := analysis generalResult particularResults at: 1.
55+
56+
self assert: result runCount equals: 1.
57+
self
58+
assert: (result mutantResults at: 1) selector
59+
equals: #testWithPragma
60+
]

src/MuTalk-Tests/MTTestCasesSelectionStrategyTest.class.st

+9-8
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ Class {
1111
{ #category : 'as yet unclassified' }
1212
MTTestCasesSelectionStrategyTest >> allTestsFromPackage [
1313

14-
^ (OrderedCollection
15-
with: MTTestClassForTestingCoverage
16-
with: MTAuxiliarTestClassForTestingStrategies
17-
with: MTAuxiliarClassForMTAnalysisTest
18-
with: MTAuxiliarTestClassForMTBudget
19-
with:
20-
MTAuxiliarTestClassForContinuingTestsExecutionAfterFirstFail
21-
with: MTAuxiliarClassForTimeTestFilterTest)
14+
^ (OrderedCollection withAll: {
15+
MTTestClassForTestingCoverage.
16+
MTAuxiliarTestClassForTestingStrategies.
17+
MTAuxiliarClassForMTAnalysisTest.
18+
MTAuxiliarTestClassForMTBudget.
19+
MTAuxiliarTestClassForContinuingTestsExecutionAfterFirstFail.
20+
MTAuxiliarClassForTimeTestFilterTest.
21+
MTAuxiliarTestClassForBlockTestFilter.
22+
MTAuxiliarTestClassForPragmaTestFilter })
2223
inject: OrderedCollection new
2324
into: [ :tests :testClass |
2425
tests addAll: testClass suite tests.

src/MuTalk-Tests/MTTimeTestFilterTest.class.st

+9-7
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,28 @@ MTTimeTestFilterTest >> runAnalysisForTimeCondition: aDuration [
1010

1111
self
1212
runAnalysisWithFilter: (MTTimeTestFilter for: aDuration)
13-
on: { MTAuxiliarClassForTimeTestFilter }
13+
on: { MTAuxiliarClassForTestFilter }
1414
withTests: { MTAuxiliarClassForTimeTestFilterTest }
1515
]
1616

17-
{ #category : 'running' }
17+
{ #category : 'tests' }
1818
MTTimeTestFilterTest >> testWith10MillisecondsCondition [
1919

20-
| testCaseReference |
20+
| testCaseReference result |
2121
testCaseReference := MTTestCaseReference
2222
for: #test10Milliseconds
2323
in: MTAuxiliarClassForTimeTestFilterTest.
2424
self runAnalysisForTimeCondition:
2525
(self timeToRunFor: testCaseReference) * 10.
26+
result := analysis generalResult particularResults at: 1.
2627

28+
self assert: result runCount equals: 1.
2729
self
28-
assert: (analysis generalResult particularResults at: 1) runCount
29-
equals: 1
30+
assert: (result mutantResults at: 1) selector
31+
equals: #test10Milliseconds
3032
]
3133

32-
{ #category : 'running' }
34+
{ #category : 'tests' }
3335
MTTimeTestFilterTest >> testWith1SecondCondition [
3436

3537
| testCaseReference |
@@ -44,7 +46,7 @@ MTTimeTestFilterTest >> testWith1SecondCondition [
4446
equals: 2
4547
]
4648

47-
{ #category : 'running' }
49+
{ #category : 'accessing' }
4850
MTTimeTestFilterTest >> timeToRunFor: aTestCaseReference [
4951

5052
aTestCaseReference runUnchecked.

0 commit comments

Comments
 (0)