From bfd1a9d099300f01485001b2e81c39912c276fcf Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Wed, 3 Apr 2024 17:40:44 +0200 Subject: [PATCH 1/8] added composite test filter --- .../MTCompositeTestFilter.class.st | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/MuTalk-Model/MTCompositeTestFilter.class.st diff --git a/src/MuTalk-Model/MTCompositeTestFilter.class.st b/src/MuTalk-Model/MTCompositeTestFilter.class.st new file mode 100644 index 0000000..f3756b4 --- /dev/null +++ b/src/MuTalk-Model/MTCompositeTestFilter.class.st @@ -0,0 +1,61 @@ +Class { + #name : 'MTCompositeTestFilter', + #superclass : 'MTTestFilter', + #instVars : [ + 'filters' + ], + #category : 'MuTalk-Model-Test filters', + #package : 'MuTalk-Model', + #tag : 'Test filters' +} + +{ #category : 'instance creation' } +MTCompositeTestFilter class >> for: aTestFilterCollection [ + + ^ self new filters: aTestFilterCollection +] + +{ #category : 'enumerating' } +MTCompositeTestFilter >> excludedTestsFrom: aTestCaseCollection [ + + | excludedTestsCollection | + excludedTestsCollection := Set new. + filters do: [ :filter | + excludedTestsCollection addAll: + ((filter excludedTestsFrom: aTestCaseCollection) collect: [ :test | + test -> filter filteredTestReason ]) ]. + ^ excludedTestsCollection asOrderedCollection +] + +{ #category : 'enumerating' } +MTCompositeTestFilter >> filterTests: aTestCaseCollection [ + + excludedTests := self excludedTestsFrom: aTestCaseCollection. + ^ filteredTests := self filteredTestsFrom: aTestCaseCollection +] + +{ #category : 'accessing' } +MTCompositeTestFilter >> filteredTestReason [ + + ^ 'Is rejected by one of the filters' +] + +{ #category : 'enumerating' } +MTCompositeTestFilter >> filteredTestsFrom: aTestCaseCollection [ + + | testCaseCollection | + ^ filters inject: aTestCaseCollection into: [ :accumulator :filter | + testCaseCollection := filter filteredTestsFrom: accumulator ] +] + +{ #category : 'accessing' } +MTCompositeTestFilter >> filters [ + + ^ filters +] + +{ #category : 'accessing' } +MTCompositeTestFilter >> filters: anObject [ + + filters := anObject +] From 7fa91479419b02b324cfd85bc970673218116047 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 4 Apr 2024 14:37:00 +0200 Subject: [PATCH 2/8] fix filtered tests appearing multiple times in general result --- src/MuTalk-Model/MTCompositeTestFilter.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MuTalk-Model/MTCompositeTestFilter.class.st b/src/MuTalk-Model/MTCompositeTestFilter.class.st index f3756b4..e5403c8 100644 --- a/src/MuTalk-Model/MTCompositeTestFilter.class.st +++ b/src/MuTalk-Model/MTCompositeTestFilter.class.st @@ -19,7 +19,7 @@ MTCompositeTestFilter class >> for: aTestFilterCollection [ MTCompositeTestFilter >> excludedTestsFrom: aTestCaseCollection [ | excludedTestsCollection | - excludedTestsCollection := Set new. + excludedTestsCollection := Dictionary new. filters do: [ :filter | excludedTestsCollection addAll: ((filter excludedTestsFrom: aTestCaseCollection) collect: [ :test | From cb4d0404cab7ec92f7f920cb983c924127435261 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 4 Apr 2024 15:22:22 +0200 Subject: [PATCH 3/8] test for composite test filter --- ...arTestClassForCompositeTestFilter.class.st | 39 +++++++++++++++++++ .../MTCompositeTestFilterTest.class.st | 30 ++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 src/MuTalk-TestResources/MTAuxiliarTestClassForCompositeTestFilter.class.st create mode 100644 src/MuTalk-Tests/MTCompositeTestFilterTest.class.st diff --git a/src/MuTalk-TestResources/MTAuxiliarTestClassForCompositeTestFilter.class.st b/src/MuTalk-TestResources/MTAuxiliarTestClassForCompositeTestFilter.class.st new file mode 100644 index 0000000..86486d1 --- /dev/null +++ b/src/MuTalk-TestResources/MTAuxiliarTestClassForCompositeTestFilter.class.st @@ -0,0 +1,39 @@ +Class { + #name : 'MTAuxiliarTestClassForCompositeTestFilter', + #superclass : 'TestCase', + #category : 'MuTalk-TestResources', + #package : 'MuTalk-TestResources' +} + +{ #category : 'tests' } +MTAuxiliarTestClassForCompositeTestFilter >> testX1 [ + + + +] + +{ #category : 'tests' } +MTAuxiliarTestClassForCompositeTestFilter >> testX2 [ + + +] + +{ #category : 'tests' } +MTAuxiliarTestClassForCompositeTestFilter >> testX3 [ + + + 100 milliSeconds wait +] + +{ #category : 'tests' } +MTAuxiliarTestClassForCompositeTestFilter >> testY1 [ + + +] + +{ #category : 'tests' } +MTAuxiliarTestClassForCompositeTestFilter >> testY2 [ + + + +] diff --git a/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st b/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st new file mode 100644 index 0000000..207a664 --- /dev/null +++ b/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st @@ -0,0 +1,30 @@ +Class { + #name : 'MTCompositeTestFilterTest', + #superclass : 'MTTestFilterTest', + #category : 'MuTalk-Tests', + #package : 'MuTalk-Tests' +} + +{ #category : 'running' } +MTCompositeTestFilterTest >> runAnalysisWithFilters: aTestFilterCollection [ + + self + runAnalysisWithFilter: + (MTCompositeTestFilter for: aTestFilterCollection) + on: { } + withTests: { MTAuxiliarTestClassForCompositeTestFilter } +] + +{ #category : 'tests' } +MTCompositeTestFilterTest >> testWithCombinedTestFilters [ + + self runAnalysisWithFilters: { + (MTBlockTestFilter for: [ :testCase | + testCase selector beginsWith: 'testX' ]). + (MTPragmaSelectionTestFilter for: #pragma). + (MTTimeTestFilter for: 10 milliSeconds) }. + analysis run. + + self assert: analysis testCases size equals: 1. + self assert: (analysis testCases at: 1) selector equals: #testX1 +] From 82cce466fc32e3cb4db8e934bef08416da32a91f Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 4 Apr 2024 15:29:33 +0200 Subject: [PATCH 4/8] rename auxiliar test class --- ...ass.st => MTAuxiliarTestClassForTimeTestFilter.class.st} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename src/MuTalk-TestResources/{MTAuxiliarClassForTimeTestFilterTest.class.st => MTAuxiliarTestClassForTimeTestFilter.class.st} (55%) diff --git a/src/MuTalk-TestResources/MTAuxiliarClassForTimeTestFilterTest.class.st b/src/MuTalk-TestResources/MTAuxiliarTestClassForTimeTestFilter.class.st similarity index 55% rename from src/MuTalk-TestResources/MTAuxiliarClassForTimeTestFilterTest.class.st rename to src/MuTalk-TestResources/MTAuxiliarTestClassForTimeTestFilter.class.st index 64b4471..15e2758 100644 --- a/src/MuTalk-TestResources/MTAuxiliarClassForTimeTestFilterTest.class.st +++ b/src/MuTalk-TestResources/MTAuxiliarTestClassForTimeTestFilter.class.st @@ -1,18 +1,18 @@ Class { - #name : 'MTAuxiliarClassForTimeTestFilterTest', + #name : 'MTAuxiliarTestClassForTimeTestFilter', #superclass : 'TestCase', #category : 'MuTalk-TestResources', #package : 'MuTalk-TestResources' } { #category : 'tests' } -MTAuxiliarClassForTimeTestFilterTest >> test10Milliseconds [ +MTAuxiliarTestClassForTimeTestFilter >> test10Milliseconds [ 10 milliSeconds wait ] { #category : 'tests' } -MTAuxiliarClassForTimeTestFilterTest >> test1Second [ +MTAuxiliarTestClassForTimeTestFilter >> test1Second [ 1 second wait ] From 70cc4046900dd2715f1973317ad6c0de48647e08 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 4 Apr 2024 15:30:31 +0200 Subject: [PATCH 5/8] refactor tests --- .../MTBlockTestFilterTest.class.st | 16 +++++----------- .../MTCompositeTestFilterTest.class.st | 1 - .../MTPragmaRejectionTestFilterTest.class.st | 19 +++++++------------ .../MTPragmaSelectionTestFilterTest.class.st | 19 +++++++------------ src/MuTalk-Tests/MTRedTestFilterTest.class.st | 4 ++-- .../MTTestCasesSelectionStrategyTest.class.st | 5 +++-- .../MTTimeTestFilterTest.class.st | 19 ++++++++----------- 7 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/MuTalk-Tests/MTBlockTestFilterTest.class.st b/src/MuTalk-Tests/MTBlockTestFilterTest.class.st index cc4d669..9c5e9c4 100644 --- a/src/MuTalk-Tests/MTBlockTestFilterTest.class.st +++ b/src/MuTalk-Tests/MTBlockTestFilterTest.class.st @@ -10,7 +10,7 @@ MTBlockTestFilterTest >> runAnalysisForBlockCondition: aBlock [ self runAnalysisWithFilter: (MTBlockTestFilter for: aBlock) - on: { MTAuxiliarClassForTestFilter } + on: { } withTests: { MTAuxiliarTestClassForBlockTestFilter } ] @@ -20,21 +20,17 @@ MTBlockTestFilterTest >> testAllTestsAreExcluded [ self runAnalysisForBlockCondition: [ :testCase | testCase selector beginsWith: 'testZ' ]. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 0 + self assert: analysis testCases size 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 + self assert: analysis testCases size equals: 1. + self assert: (analysis testCases at: 1) selector equals: #testX ] { #category : 'tests' } @@ -43,7 +39,5 @@ MTBlockTestFilterTest >> testYTestIsNotExcluded [ self runAnalysisForBlockCondition: [ :testCase | testCase selector beginsWith: 'test' ]. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 2 + self assert: analysis testCases size equals: 2 ] diff --git a/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st b/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st index 207a664..eb02ef4 100644 --- a/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st +++ b/src/MuTalk-Tests/MTCompositeTestFilterTest.class.st @@ -23,7 +23,6 @@ MTCompositeTestFilterTest >> testWithCombinedTestFilters [ testCase selector beginsWith: 'testX' ]). (MTPragmaSelectionTestFilter for: #pragma). (MTTimeTestFilter for: 10 milliSeconds) }. - analysis run. self assert: analysis testCases size equals: 1. self assert: (analysis testCases at: 1) selector equals: #testX1 diff --git a/src/MuTalk-Tests/MTPragmaRejectionTestFilterTest.class.st b/src/MuTalk-Tests/MTPragmaRejectionTestFilterTest.class.st index 3e5548a..084c903 100644 --- a/src/MuTalk-Tests/MTPragmaRejectionTestFilterTest.class.st +++ b/src/MuTalk-Tests/MTPragmaRejectionTestFilterTest.class.st @@ -11,7 +11,7 @@ MTPragmaRejectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelecto self runAnalysisWithFilter: (MTPragmaRejectionTestFilter for: aPragmaSelector) - on: { MTAuxiliarClassForTestFilter } + on: { } withTests: { MTAuxiliarTestClassForPragmaTestFilter } ] @@ -22,20 +22,19 @@ MTPragmaRejectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelecto runAnalysisWithFilter: (MTPragmaRejectionTestFilter for: aPragmaSelector arguments: pragmaArguments) - on: { MTAuxiliarClassForTestFilter } + on: { } withTests: { MTAuxiliarTestClassForPragmaTestFilter } ] { #category : 'tests' } MTPragmaRejectionTestFilterTest >> testTestWithPragmaIsExcluded [ - | result | self runAnalysisForPragmaCondition: #aPragma. - result := analysis generalResult particularResults at: 1. - self assert: result runCount equals: 1. + + self assert: analysis testCases size equals: 1. self - assert: (result mutantResults at: 1) selector + assert: (analysis testCases at: 1) selector equals: #testWithoutPragma ] @@ -44,9 +43,7 @@ MTPragmaRejectionTestFilterTest >> testTestWithPragmaIsNotExcluded [ self runAnalysisForPragmaCondition: #anotherPragma. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 2 + self assert: analysis testCases size equals: 2 ] { #category : 'tests' } @@ -54,7 +51,5 @@ MTPragmaRejectionTestFilterTest >> testTestWithPragmaIsNotExcluded2 [ self runAnalysisForPragmaCondition: #aPragma: andArguments: 'arg'. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 2 + self assert: analysis testCases size equals: 2 ] diff --git a/src/MuTalk-Tests/MTPragmaSelectionTestFilterTest.class.st b/src/MuTalk-Tests/MTPragmaSelectionTestFilterTest.class.st index 2235d8a..05436ee 100644 --- a/src/MuTalk-Tests/MTPragmaSelectionTestFilterTest.class.st +++ b/src/MuTalk-Tests/MTPragmaSelectionTestFilterTest.class.st @@ -11,7 +11,7 @@ MTPragmaSelectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelecto self runAnalysisWithFilter: (MTPragmaSelectionTestFilter for: aPragmaSelector) - on: { MTAuxiliarClassForTestFilter } + on: { } withTests: { MTAuxiliarTestClassForPragmaTestFilter } ] @@ -22,7 +22,7 @@ MTPragmaSelectionTestFilterTest >> runAnalysisForPragmaCondition: aPragmaSelecto runAnalysisWithFilter: (MTPragmaSelectionTestFilter for: aPragmaSelector arguments: pragmaArguments) - on: { MTAuxiliarClassForTestFilter } + on: { } withTests: { MTAuxiliarTestClassForPragmaTestFilter } ] @@ -31,9 +31,7 @@ MTPragmaSelectionTestFilterTest >> testAllTestsAreExcluded [ self runAnalysisForPragmaCondition: #anotherPragma. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 0 + self assert: analysis testCases size equals: 0 ] { #category : 'tests' } @@ -41,20 +39,17 @@ MTPragmaSelectionTestFilterTest >> testAllTestsAreExcluded2 [ self runAnalysisForPragmaCondition: #aPragma: andArguments: { 'arg' }. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 0 + self assert: analysis testCases size equals: 0 ] { #category : 'tests' } MTPragmaSelectionTestFilterTest >> testTestWithoutPragmaIsExcluded [ - | result | self runAnalysisForPragmaCondition: #aPragma. - result := analysis generalResult particularResults at: 1. - self assert: result runCount equals: 1. + + self assert: analysis testCases size equals: 1. self - assert: (result mutantResults at: 1) selector + assert: (analysis testCases at: 1) selector equals: #testWithPragma ] diff --git a/src/MuTalk-Tests/MTRedTestFilterTest.class.st b/src/MuTalk-Tests/MTRedTestFilterTest.class.st index b03739c..374902d 100644 --- a/src/MuTalk-Tests/MTRedTestFilterTest.class.st +++ b/src/MuTalk-Tests/MTRedTestFilterTest.class.st @@ -9,8 +9,8 @@ Class { MTRedTestFilterTest >> runAnalysis [ self - runAnalysisWithFilter: (MTRedTestFilter new) - on: { MTAuxiliarClassForTestFilter } + runAnalysisWithFilter: MTRedTestFilter new + on: { } withTests: { MTAuxiliarTestClassForRedTestFilter } ] diff --git a/src/MuTalk-Tests/MTTestCasesSelectionStrategyTest.class.st b/src/MuTalk-Tests/MTTestCasesSelectionStrategyTest.class.st index 586e15c..74b74e7 100644 --- a/src/MuTalk-Tests/MTTestCasesSelectionStrategyTest.class.st +++ b/src/MuTalk-Tests/MTTestCasesSelectionStrategyTest.class.st @@ -17,11 +17,12 @@ MTTestCasesSelectionStrategyTest >> allTestsFromPackage [ MTAuxiliarClassForMTAnalysisTest. MTAuxiliarTestClassForMTBudget. MTAuxiliarTestClassForContinuingTestsExecutionAfterFirstFail. - MTAuxiliarClassForTimeTestFilterTest. + MTAuxiliarTestClassForTimeTestFilter. MTAuxiliarTestClassForBlockTestFilter. MTAuxiliarTestClassForPragmaTestFilter. MTAuxiliarTestClassForRedTestFilter. - MTAuxiliarParametrizedTestClass }) + MTAuxiliarParametrizedTestClass. + MTAuxiliarTestClassForCompositeTestFilter }) inject: OrderedCollection new into: [ :tests :testClass | tests addAll: testClass suite tests. diff --git a/src/MuTalk-Tests/MTTimeTestFilterTest.class.st b/src/MuTalk-Tests/MTTimeTestFilterTest.class.st index 9de92a3..4bf729b 100644 --- a/src/MuTalk-Tests/MTTimeTestFilterTest.class.st +++ b/src/MuTalk-Tests/MTTimeTestFilterTest.class.st @@ -10,24 +10,23 @@ MTTimeTestFilterTest >> runAnalysisForTimeCondition: aDuration [ self runAnalysisWithFilter: (MTTimeTestFilter for: aDuration) - on: { MTAuxiliarClassForTestFilter } - withTests: { MTAuxiliarClassForTimeTestFilterTest } + on: { } + withTests: { MTAuxiliarTestClassForTimeTestFilter } ] { #category : 'tests' } MTTimeTestFilterTest >> testWith10MillisecondsCondition [ - | testCaseReference result testCase | - testCase := MTAuxiliarClassForTimeTestFilterTest selector: + | testCaseReference testCase | + testCase := MTAuxiliarTestClassForTimeTestFilter selector: #test10Milliseconds. testCaseReference := MTTestCaseReference for: testCase. self runAnalysisForTimeCondition: (self timeToRunFor: testCaseReference) * 10. - result := analysis generalResult particularResults at: 1. - self assert: result runCount equals: 1. + self assert: analysis testCases size equals: 1. self - assert: (result mutantResults at: 1) selector + assert: (analysis testCases at: 1) selector equals: #test10Milliseconds ] @@ -35,15 +34,13 @@ MTTimeTestFilterTest >> testWith10MillisecondsCondition [ MTTimeTestFilterTest >> testWith1SecondCondition [ | testCaseReference testCase | - testCase := MTAuxiliarClassForTimeTestFilterTest selector: + testCase := MTAuxiliarTestClassForTimeTestFilter selector: #test1Second. testCaseReference := MTTestCaseReference for: testCase. self runAnalysisForTimeCondition: (self timeToRunFor: testCaseReference) * 10. - self - assert: (analysis generalResult particularResults at: 1) runCount - equals: 2 + self assert: analysis testCases size equals: 2 ] { #category : 'accessing' } From 06697d0d6d210c711740247a8fedeb3b80f02164 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 4 Apr 2024 15:56:30 +0200 Subject: [PATCH 6/8] removed unused method & fix class side method --- src/MuTalk-Model/MTCompositeTestFilter.class.st | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/MuTalk-Model/MTCompositeTestFilter.class.st b/src/MuTalk-Model/MTCompositeTestFilter.class.st index e5403c8..ef6c616 100644 --- a/src/MuTalk-Model/MTCompositeTestFilter.class.st +++ b/src/MuTalk-Model/MTCompositeTestFilter.class.st @@ -12,7 +12,9 @@ Class { { #category : 'instance creation' } MTCompositeTestFilter class >> for: aTestFilterCollection [ - ^ self new filters: aTestFilterCollection + ^ self new + filters: aTestFilterCollection; + yourself ] { #category : 'enumerating' } @@ -34,12 +36,6 @@ MTCompositeTestFilter >> filterTests: aTestCaseCollection [ ^ filteredTests := self filteredTestsFrom: aTestCaseCollection ] -{ #category : 'accessing' } -MTCompositeTestFilter >> filteredTestReason [ - - ^ 'Is rejected by one of the filters' -] - { #category : 'enumerating' } MTCompositeTestFilter >> filteredTestsFrom: aTestCaseCollection [ From 656a29a33699e93bbbea6ba62870aab939145d34 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 4 Apr 2024 15:57:43 +0200 Subject: [PATCH 7/8] remove unused class --- .../MTAuxiliarClassForTestFilter.class.st | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 src/MuTalk-TestResources/MTAuxiliarClassForTestFilter.class.st diff --git a/src/MuTalk-TestResources/MTAuxiliarClassForTestFilter.class.st b/src/MuTalk-TestResources/MTAuxiliarClassForTestFilter.class.st deleted file mode 100644 index 46cf3f7..0000000 --- a/src/MuTalk-TestResources/MTAuxiliarClassForTestFilter.class.st +++ /dev/null @@ -1,12 +0,0 @@ -Class { - #name : 'MTAuxiliarClassForTestFilter', - #superclass : 'Object', - #category : 'MuTalk-TestResources', - #package : 'MuTalk-TestResources' -} - -{ #category : 'accessing' } -MTAuxiliarClassForTestFilter >> simpleMethod [ - - ^ 1 + 1 -] From bec067294b7d5bb6ae19176da23636f62094b7e3 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Tue, 9 Apr 2024 14:00:48 +0200 Subject: [PATCH 8/8] added class comment --- src/MuTalk-Model/MTCompositeTestFilter.class.st | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MuTalk-Model/MTCompositeTestFilter.class.st b/src/MuTalk-Model/MTCompositeTestFilter.class.st index ef6c616..58f1ff7 100644 --- a/src/MuTalk-Model/MTCompositeTestFilter.class.st +++ b/src/MuTalk-Model/MTCompositeTestFilter.class.st @@ -1,3 +1,7 @@ +" +This test filter is a composition of multiple test filters. +It works as if the test collection passes through each test filter one by one. So a test is blocked by the composite test filter if any of its filters blocks the said test. In the same way, a test passes through the composite test filter if it passes through every of its filters. +" Class { #name : 'MTCompositeTestFilter', #superclass : 'MTTestFilter',