-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New test filters #82
Merged
guillep
merged 12 commits into
pharo-contributions:master
from
DurieuxPol:feat/moreTestFilters
Feb 22, 2024
Merged
New test filters #82
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a1ae4e2
implemented block and pragma test filters
4d84714
implemented tests for pragma filter & renames auxiliar class for test…
b7c9cd0
protocol name fix
f2081f7
implemented tests for block filter
e533d1b
renamed auxiliar test class for pragma test filter
7b0386a
refactoring tests
7fb332f
fix
c954465
refactor pragma test filters, now one that rejects and one that selects
58ced24
moved down class methods
ab2b553
tests for both pragma test filters
1e836a0
moved up class methods
4bc106f
fix error in isAbstract
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
Class { | ||
#name : 'MTBlockTestFilter', | ||
#superclass : 'MTTestFilter', | ||
#category : 'MuTalk-Model-Test filters', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Test filters' | ||
} | ||
|
||
{ #category : 'enumerating' } | ||
MTBlockTestFilter >> filterTests: aTestCaseCollection [ | ||
|
||
^ aTestCaseCollection select: condition | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
Class { | ||
#name : 'MTPragmaTestFilter', | ||
#superclass : 'MTTestFilter', | ||
#instVars : [ | ||
'pragmaArguments' | ||
], | ||
#category : 'MuTalk-Model-Test filters', | ||
#package : 'MuTalk-Model', | ||
#tag : 'Test filters' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
MTPragmaTestFilter class >> for: aPragmaSelector [ | ||
|
||
^ self new | ||
condition: aPragmaSelector; | ||
pragmaArguments: #( ); | ||
yourself | ||
] | ||
|
||
{ #category : 'instance creation' } | ||
MTPragmaTestFilter class >> for: aPragmaSelector arguments: pragmaArguments [ | ||
|
||
^ self new | ||
condition: aPragmaSelector; | ||
pragmaArguments: pragmaArguments; | ||
yourself | ||
] | ||
|
||
{ #category : 'enumerating' } | ||
MTPragmaTestFilter >> filterTests: aTestCaseCollection [ | ||
|
||
^ aTestCaseCollection reject: [ :testCaseReference | | ||
| pragmas | | ||
pragmas := testCaseReference method pragmas. | ||
pragmas anySatisfy: [ :pragma | | ||
pragma selector = condition | ||
& (pragma arguments = pragmaArguments) ] ] | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTPragmaTestFilter >> pragmaArguments [ | ||
|
||
^ pragmaArguments | ||
] | ||
|
||
{ #category : 'accessing' } | ||
MTPragmaTestFilter >> pragmaArguments: anObject [ | ||
|
||
pragmaArguments := anObject | ||
] |
4 changes: 2 additions & 2 deletions
4
...MTAuxiliarClassForTimeTestFilter.class.st → ...ces/MTAuxiliarClassForTestFilter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
Class { | ||
#name : 'MTAuxiliarClassForTimeTestFilter', | ||
#name : 'MTAuxiliarClassForTestFilter', | ||
#superclass : 'Object', | ||
#category : 'MuTalk-TestResources', | ||
#package : 'MuTalk-TestResources' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
MTAuxiliarClassForTimeTestFilter >> simpleMethod [ | ||
MTAuxiliarClassForTestFilter >> simpleMethod [ | ||
|
||
^ 1 + 1 | ||
] |
18 changes: 18 additions & 0 deletions
18
src/MuTalk-TestResources/MTAuxiliarTestClassForBlockTestFilter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Class { | ||
#name : 'MTAuxiliarTestClassForBlockTestFilter', | ||
#superclass : 'TestCase', | ||
#category : 'MuTalk-TestResources', | ||
#package : 'MuTalk-TestResources' | ||
} | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForBlockTestFilter >> testX [ | ||
|
||
self assert: true | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForBlockTestFilter >> testY [ | ||
|
||
self assert: true | ||
] |
19 changes: 19 additions & 0 deletions
19
src/MuTalk-TestResources/MTAuxiliarTestClassForPragmaTestFilter.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Class { | ||
#name : 'MTAuxiliarTestClassForPragmaTestFilter', | ||
#superclass : 'TestCase', | ||
#category : 'MuTalk-TestResources', | ||
#package : 'MuTalk-TestResources' | ||
} | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForPragmaTestFilter >> testWithPragma [ | ||
|
||
<aPragma> | ||
self assert: true | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTAuxiliarTestClassForPragmaTestFilter >> testWithoutPragma [ | ||
|
||
self assert: true | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Class { | ||
#name : 'MTBlockTestFilterTest', | ||
#superclass : 'MTTestFilterTest', | ||
#category : 'MuTalk-Tests', | ||
#package : 'MuTalk-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
MTBlockTestFilterTest >> runAnalysisForBlockCondition: aBlock [ | ||
|
||
self | ||
runAnalysisWithFilter: (MTBlockTestFilter for: aBlock) | ||
on: { MTAuxiliarClassForTestFilter } | ||
withTests: { MTAuxiliarTestClassForBlockTestFilter } | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTBlockTestFilterTest >> testAllTestsAreExcluded [ | ||
|
||
self runAnalysisForBlockCondition: [ :testCase | | ||
testCase selector beginsWith: 'testZ' ]. | ||
|
||
self | ||
assert: (analysis generalResult particularResults at: 1) runCount | ||
equals: 0 | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTBlockTestFilterTest >> testYTestIsExcluded [ | ||
|
||
| result | | ||
self runAnalysisForBlockCondition: [ :testCase | | ||
testCase selector beginsWith: 'testX' ]. | ||
result := analysis generalResult particularResults at: 1. | ||
|
||
self assert: result runCount equals: 1. | ||
self assert: (result mutantResults at: 1) selector equals: #testX | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTBlockTestFilterTest >> testYTestIsNotExcluded [ | ||
|
||
self runAnalysisForBlockCondition: [ :testCase | | ||
testCase selector beginsWith: 'test' ]. | ||
|
||
self | ||
assert: (analysis generalResult particularResults at: 1) runCount | ||
equals: 2 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Class { | ||
#name : 'MTPragmaTestFilterTest', | ||
#superclass : 'MTTestFilterTest', | ||
#category : 'MuTalk-Tests', | ||
#package : 'MuTalk-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
MTPragmaTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelector [ | ||
|
||
self | ||
runAnalysisWithFilter: (MTPragmaTestFilter for: aPragmaSelector) | ||
on: { MTAuxiliarClassForTestFilter } | ||
withTests: { MTAuxiliarTestClassForPragmaTestFilter } | ||
] | ||
|
||
{ #category : 'running' } | ||
MTPragmaTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelector andArguments: pragmaArguments [ | ||
|
||
self | ||
runAnalysisWithFilter: | ||
(MTPragmaTestFilter for: aPragmaSelector arguments: pragmaArguments) | ||
on: { MTAuxiliarClassForTestFilter } | ||
withTests: { MTAuxiliarTestClassForPragmaTestFilter } | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTPragmaTestFilterTest >> testTestWithPragmaIsExcluded [ | ||
|
||
| result | | ||
self runAnalysisForPragmaCondition: #aPragma. | ||
result := analysis generalResult particularResults at: 1. | ||
|
||
self assert: result runCount equals: 1. | ||
self | ||
assert: (result mutantResults at: 1) selector | ||
equals: #testWithoutPragma | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTPragmaTestFilterTest >> testTestWithPragmaIsNotExcluded [ | ||
|
||
self runAnalysisForPragmaCondition: #anotherPragma. | ||
|
||
self | ||
assert: (analysis generalResult particularResults at: 1) runCount | ||
equals: 2 | ||
] | ||
|
||
{ #category : 'tests' } | ||
MTPragmaTestFilterTest >> testTestWithPragmaIsNotExcluded2 [ | ||
|
||
self runAnalysisForPragmaCondition: #aPragma: andArguments: 'arg'. | ||
|
||
self | ||
assert: (analysis generalResult particularResults at: 1) runCount | ||
equals: 2 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes this seems nicer!