From 9af9b43532cb0185e6c1bf67f2aa574779db4364 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Thu, 14 Dec 2023 17:51:24 +0100 Subject: [PATCH 1/3] rename all mutation testing budget classes to MT budget classes, and refactor start method --- src/MuTalk-Model/MTBudget.class.st | 43 +++++++++++++++++++ .../MTFixedNumberOfMutantsBudget.class.st | 12 ++++++ src/MuTalk-Model/MTFreeBudget.class.st | 12 ++++++ .../MTPercentageOfMutantsBudget.class.st | 13 ++++++ ...eBudget.class.st => MTTimeBudget.class.st} | 8 ++-- .../MutationTestingAnalysis.class.st | 2 +- .../MutationTestingBudget.class.st | 41 ------------------ ...TestingFixedNumberOfMutantsBudget.class.st | 18 -------- .../MutationTestingFreeBudget.class.st | 18 -------- ...nTestingPercentageOfMutantsBudget.class.st | 19 -------- ...s.st => AuxiliarClassForMTBudget.class.st} | 4 +- ... => AuxiliarTestClassForMTBudget.class.st} | 4 +- ...getTest.class.st => MTBudgetTest.class.st} | 6 +-- ...MTFixedNumberOfMutantsBudgetTest.class.st} | 16 +++---- ... MTPercentageOfMutantsBudgetTest.class.st} | 16 +++---- ...est.class.st => MTTimeBudgetTest.class.st} | 24 +++++------ .../TestCasesSelectionStrategyTest.class.st | 2 +- 17 files changed, 121 insertions(+), 137 deletions(-) create mode 100644 src/MuTalk-Model/MTBudget.class.st create mode 100644 src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st create mode 100644 src/MuTalk-Model/MTFreeBudget.class.st create mode 100644 src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st rename src/MuTalk-Model/{MutationTestingTimeBudget.class.st => MTTimeBudget.class.st} (62%) delete mode 100644 src/MuTalk-Model/MutationTestingBudget.class.st delete mode 100644 src/MuTalk-Model/MutationTestingFixedNumberOfMutantsBudget.class.st delete mode 100644 src/MuTalk-Model/MutationTestingFreeBudget.class.st delete mode 100644 src/MuTalk-Model/MutationTestingPercentageOfMutantsBudget.class.st rename src/MuTalk-TestResources/{AuxiliarClassForMutationTestingBudget.class.st => AuxiliarClassForMTBudget.class.st} (60%) rename src/MuTalk-TestResources/{AuxiliarTestClassForMutationTestingBudget.class.st => AuxiliarTestClassForMTBudget.class.st} (60%) rename src/MuTalk-Tests/{MutationTestingBudgetTest.class.st => MTBudgetTest.class.st} (73%) rename src/MuTalk-Tests/{MutationTestingFixedNumberOfMutantsBudgetTest.class.st => MTFixedNumberOfMutantsBudgetTest.class.st} (52%) rename src/MuTalk-Tests/{MutationTestingPercentageOfMutantsBudgetTest.class.st => MTPercentageOfMutantsBudgetTest.class.st} (60%) rename src/MuTalk-Tests/{MutationTestingTimeBudgetTest.class.st => MTTimeBudgetTest.class.st} (76%) diff --git a/src/MuTalk-Model/MTBudget.class.st b/src/MuTalk-Model/MTBudget.class.st new file mode 100644 index 00000000..d5940078 --- /dev/null +++ b/src/MuTalk-Model/MTBudget.class.st @@ -0,0 +1,43 @@ +Class { + #name : 'MTBudget', + #superclass : 'Object', + #instVars : [ + 'constraint' + ], + #category : 'MuTalk-Model', + #package : 'MuTalk-Model' +} + +{ #category : 'instance creation' } +MTBudget class >> for: aConstraint [ + + ^ self new + constraint: aConstraint; + yourself +] + +{ #category : 'validation' } +MTBudget >> check: partialCollection with: initialCollection [ + + ^ self subclassResponsibility +] + +{ #category : 'accessing' } +MTBudget >> constraint [ + + ^ constraint +] + +{ #category : 'accessing' } +MTBudget >> constraint: aConstraint [ + + constraint := aConstraint +] + +{ #category : 'accessing' } +MTBudget >> start [ + "Does nothing for most budgets because they don't need specific data at the start of the execution of the mutation testing analysis, but some do (time budget for example). + In this case, this method should be overriden." + + +] diff --git a/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st b/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st new file mode 100644 index 00000000..98a866c4 --- /dev/null +++ b/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st @@ -0,0 +1,12 @@ +Class { + #name : 'MTFixedNumberOfMutantsBudget', + #superclass : 'MTBudget', + #category : 'MuTalk-Model', + #package : 'MuTalk-Model' +} + +{ #category : 'validation' } +MTFixedNumberOfMutantsBudget >> check: partialCollection with: initialCollection [ + + ^ partialCollection size >= constraint +] diff --git a/src/MuTalk-Model/MTFreeBudget.class.st b/src/MuTalk-Model/MTFreeBudget.class.st new file mode 100644 index 00000000..242aee29 --- /dev/null +++ b/src/MuTalk-Model/MTFreeBudget.class.st @@ -0,0 +1,12 @@ +Class { + #name : 'MTFreeBudget', + #superclass : 'MTBudget', + #category : 'MuTalk-Model', + #package : 'MuTalk-Model' +} + +{ #category : 'validation' } +MTFreeBudget >> check: partialCollection with: initialCollection [ + + ^ false +] diff --git a/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st b/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st new file mode 100644 index 00000000..db5e01ec --- /dev/null +++ b/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st @@ -0,0 +1,13 @@ +Class { + #name : 'MTPercentageOfMutantsBudget', + #superclass : 'MTBudget', + #category : 'MuTalk-Model', + #package : 'MuTalk-Model' +} + +{ #category : 'validation' } +MTPercentageOfMutantsBudget >> check: partialCollection with: initialCollection [ + + ^ partialCollection size + >= (constraint / 100 * initialCollection size) +] diff --git a/src/MuTalk-Model/MutationTestingTimeBudget.class.st b/src/MuTalk-Model/MTTimeBudget.class.st similarity index 62% rename from src/MuTalk-Model/MutationTestingTimeBudget.class.st rename to src/MuTalk-Model/MTTimeBudget.class.st index 2e182396..7ed0e807 100644 --- a/src/MuTalk-Model/MutationTestingTimeBudget.class.st +++ b/src/MuTalk-Model/MTTimeBudget.class.st @@ -1,6 +1,6 @@ Class { - #name : 'MutationTestingTimeBudget', - #superclass : 'MutationTestingBudget', + #name : 'MTTimeBudget', + #superclass : 'MTBudget', #instVars : [ 'initialTime' ], @@ -9,7 +9,7 @@ Class { } { #category : 'validation' } -MutationTestingTimeBudget >> check: partialCollection with: initialCollection [ +MTTimeBudget >> check: partialCollection with: initialCollection [ | currentTime | currentTime := Time current asMilliSeconds. @@ -17,7 +17,7 @@ MutationTestingTimeBudget >> check: partialCollection with: initialCollection [ ] { #category : 'accessing' } -MutationTestingTimeBudget >> start [ +MTTimeBudget >> start [ initialTime := Time current asMilliSeconds ] diff --git a/src/MuTalk-Model/MutationTestingAnalysis.class.st b/src/MuTalk-Model/MutationTestingAnalysis.class.st index 79e95341..489090b4 100644 --- a/src/MuTalk-Model/MutationTestingAnalysis.class.st +++ b/src/MuTalk-Model/MutationTestingAnalysis.class.st @@ -31,7 +31,7 @@ MutationTestingAnalysis class >> defaultMutantsEvaluationStrategy [ { #category : 'defaults' } MutationTestingAnalysis class >> defaultMutationTestingBudget [ - ^ MutationTestingFreeBudget new + ^ MTFreeBudget new ] { #category : 'defaults' } diff --git a/src/MuTalk-Model/MutationTestingBudget.class.st b/src/MuTalk-Model/MutationTestingBudget.class.st deleted file mode 100644 index ddd24819..00000000 --- a/src/MuTalk-Model/MutationTestingBudget.class.st +++ /dev/null @@ -1,41 +0,0 @@ -Class { - #name : 'MutationTestingBudget', - #superclass : 'Object', - #instVars : [ - 'constraint' - ], - #category : 'MuTalk-Model', - #package : 'MuTalk-Model' -} - -{ #category : 'instance creation' } -MutationTestingBudget class >> for: aConstraint [ - - ^ self new - constraint: aConstraint; - yourself -] - -{ #category : 'validation' } -MutationTestingBudget >> check: partialCollection with: initialCollection [ - - ^ self subclassResponsibility -] - -{ #category : 'accessing' } -MutationTestingBudget >> constraint [ - - ^ constraint -] - -{ #category : 'accessing' } -MutationTestingBudget >> constraint: aConstraint [ - - constraint := aConstraint -] - -{ #category : 'accessing' } -MutationTestingBudget >> start [ - - ^ self subclassResponsibility -] diff --git a/src/MuTalk-Model/MutationTestingFixedNumberOfMutantsBudget.class.st b/src/MuTalk-Model/MutationTestingFixedNumberOfMutantsBudget.class.st deleted file mode 100644 index befa8744..00000000 --- a/src/MuTalk-Model/MutationTestingFixedNumberOfMutantsBudget.class.st +++ /dev/null @@ -1,18 +0,0 @@ -Class { - #name : 'MutationTestingFixedNumberOfMutantsBudget', - #superclass : 'MutationTestingBudget', - #category : 'MuTalk-Model', - #package : 'MuTalk-Model' -} - -{ #category : 'validation' } -MutationTestingFixedNumberOfMutantsBudget >> check: partialCollection with: initialCollection [ - - ^ partialCollection size >= constraint -] - -{ #category : 'accessing' } -MutationTestingFixedNumberOfMutantsBudget >> start [ - - -] diff --git a/src/MuTalk-Model/MutationTestingFreeBudget.class.st b/src/MuTalk-Model/MutationTestingFreeBudget.class.st deleted file mode 100644 index 6878ea0b..00000000 --- a/src/MuTalk-Model/MutationTestingFreeBudget.class.st +++ /dev/null @@ -1,18 +0,0 @@ -Class { - #name : 'MutationTestingFreeBudget', - #superclass : 'MutationTestingBudget', - #category : 'MuTalk-Model', - #package : 'MuTalk-Model' -} - -{ #category : 'validation' } -MutationTestingFreeBudget >> check: partialCollection with: initialCollection [ - - ^ false -] - -{ #category : 'accessing' } -MutationTestingFreeBudget >> start [ - - -] diff --git a/src/MuTalk-Model/MutationTestingPercentageOfMutantsBudget.class.st b/src/MuTalk-Model/MutationTestingPercentageOfMutantsBudget.class.st deleted file mode 100644 index 7c2e95e7..00000000 --- a/src/MuTalk-Model/MutationTestingPercentageOfMutantsBudget.class.st +++ /dev/null @@ -1,19 +0,0 @@ -Class { - #name : 'MutationTestingPercentageOfMutantsBudget', - #superclass : 'MutationTestingBudget', - #category : 'MuTalk-Model', - #package : 'MuTalk-Model' -} - -{ #category : 'validation' } -MutationTestingPercentageOfMutantsBudget >> check: partialCollection with: initialCollection [ - - ^ partialCollection size - >= (constraint / 100 * initialCollection size) -] - -{ #category : 'accessing' } -MutationTestingPercentageOfMutantsBudget >> start [ - - -] diff --git a/src/MuTalk-TestResources/AuxiliarClassForMutationTestingBudget.class.st b/src/MuTalk-TestResources/AuxiliarClassForMTBudget.class.st similarity index 60% rename from src/MuTalk-TestResources/AuxiliarClassForMutationTestingBudget.class.st rename to src/MuTalk-TestResources/AuxiliarClassForMTBudget.class.st index 0178abdd..70290678 100644 --- a/src/MuTalk-TestResources/AuxiliarClassForMutationTestingBudget.class.st +++ b/src/MuTalk-TestResources/AuxiliarClassForMTBudget.class.st @@ -1,12 +1,12 @@ Class { - #name : 'AuxiliarClassForMutationTestingBudget', + #name : 'AuxiliarClassForMTBudget', #superclass : 'Object', #category : 'MuTalk-TestResources', #package : 'MuTalk-TestResources' } { #category : 'arithmetic' } -AuxiliarClassForMutationTestingBudget >> nil [ +AuxiliarClassForMTBudget >> nil [ ^ nil ] diff --git a/src/MuTalk-TestResources/AuxiliarTestClassForMutationTestingBudget.class.st b/src/MuTalk-TestResources/AuxiliarTestClassForMTBudget.class.st similarity index 60% rename from src/MuTalk-TestResources/AuxiliarTestClassForMutationTestingBudget.class.st rename to src/MuTalk-TestResources/AuxiliarTestClassForMTBudget.class.st index da739272..aa4e52a3 100644 --- a/src/MuTalk-TestResources/AuxiliarTestClassForMutationTestingBudget.class.st +++ b/src/MuTalk-TestResources/AuxiliarTestClassForMTBudget.class.st @@ -1,5 +1,5 @@ Class { - #name : 'AuxiliarTestClassForMutationTestingBudget', + #name : 'AuxiliarTestClassForMTBudget', #superclass : 'TestCase', #instVars : [ 'object' @@ -9,7 +9,7 @@ Class { } { #category : 'tests' } -AuxiliarTestClassForMutationTestingBudget >> testNil [ +AuxiliarTestClassForMTBudget >> testNil [ ] diff --git a/src/MuTalk-Tests/MutationTestingBudgetTest.class.st b/src/MuTalk-Tests/MTBudgetTest.class.st similarity index 73% rename from src/MuTalk-Tests/MutationTestingBudgetTest.class.st rename to src/MuTalk-Tests/MTBudgetTest.class.st index fd3b138a..1a6842d4 100644 --- a/src/MuTalk-Tests/MutationTestingBudgetTest.class.st +++ b/src/MuTalk-Tests/MTBudgetTest.class.st @@ -1,5 +1,5 @@ Class { - #name : 'MutationTestingBudgetTest', + #name : 'MTBudgetTest', #superclass : 'TestCase', #instVars : [ 'analysis' @@ -9,13 +9,13 @@ Class { } { #category : 'running' } -MutationTestingBudgetTest >> runAnalysisFor: aConstraint [ +MTBudgetTest >> runAnalysisFor: aConstraint [ ^ self subclassResponsibility ] { #category : 'running' } -MutationTestingBudgetTest >> runAnalysisWithBudget: aBudget on: classesToMutate withTests: testCases [ +MTBudgetTest >> runAnalysisWithBudget: aBudget on: classesToMutate withTests: testCases [ analysis := MutationTestingAnalysis testCasesFrom: testCases diff --git a/src/MuTalk-Tests/MutationTestingFixedNumberOfMutantsBudgetTest.class.st b/src/MuTalk-Tests/MTFixedNumberOfMutantsBudgetTest.class.st similarity index 52% rename from src/MuTalk-Tests/MutationTestingFixedNumberOfMutantsBudgetTest.class.st rename to src/MuTalk-Tests/MTFixedNumberOfMutantsBudgetTest.class.st index 49267002..0bae3577 100644 --- a/src/MuTalk-Tests/MutationTestingFixedNumberOfMutantsBudgetTest.class.st +++ b/src/MuTalk-Tests/MTFixedNumberOfMutantsBudgetTest.class.st @@ -1,21 +1,21 @@ Class { - #name : 'MutationTestingFixedNumberOfMutantsBudgetTest', - #superclass : 'MutationTestingBudgetTest', + #name : 'MTFixedNumberOfMutantsBudgetTest', + #superclass : 'MTBudgetTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } { #category : 'running' } -MutationTestingFixedNumberOfMutantsBudgetTest >> runAnalysisFor: aNumber [ +MTFixedNumberOfMutantsBudgetTest >> runAnalysisFor: aNumber [ ^ self - runAnalysisWithBudget: (MutationTestingFixedNumberOfMutantsBudget for: aNumber) + runAnalysisWithBudget: (MTFixedNumberOfMutantsBudget for: aNumber) on: { AuxiliarClassForMutationTestingAnalysis } withTests: { AuxiliarClassForMutationTestingAnalysisTest } ] { #category : 'tests' } -MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateAllMutantsWithConstraintGreaterThanActualNumberOfMutations [ +MTFixedNumberOfMutantsBudgetTest >> testEvaluateAllMutantsWithConstraintGreaterThanActualNumberOfMutations [ self runAnalysisFor: 50. self @@ -24,7 +24,7 @@ MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateAllMutantsWithConst ] { #category : 'tests' } -MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateTheCorrectNumberOfMutants [ +MTFixedNumberOfMutantsBudgetTest >> testEvaluateTheCorrectNumberOfMutants [ self runAnalysisFor: 10. self @@ -33,7 +33,7 @@ MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateTheCorrectNumberOfM ] { #category : 'tests' } -MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithConstraintOfZero [ +MTFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithConstraintOfZero [ self runAnalysisFor: 0. self @@ -42,7 +42,7 @@ MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithCons ] { #category : 'tests' } -MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithNegativeConstraint [ +MTFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithNegativeConstraint [ self runAnalysisFor: -10. self diff --git a/src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st b/src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st similarity index 60% rename from src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st rename to src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st index 8074a3ae..3419baa2 100644 --- a/src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st +++ b/src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st @@ -1,6 +1,6 @@ Class { - #name : 'MutationTestingPercentageOfMutantsBudgetTest', - #superclass : 'MutationTestingBudgetTest', + #name : 'MTPercentageOfMutantsBudgetTest', + #superclass : 'MTBudgetTest', #instVars : [ 'numberOfMutations' ], @@ -9,12 +9,12 @@ Class { } { #category : 'running' } -MutationTestingPercentageOfMutantsBudgetTest >> runAnalysisFor: aPercentage [ +MTPercentageOfMutantsBudgetTest >> runAnalysisFor: aPercentage [ | result | result := self runAnalysisWithBudget: - (MutationTestingPercentageOfMutantsBudget for: aPercentage) + (MTPercentageOfMutantsBudget for: aPercentage) on: { AuxiliarClassForMutationTestingAnalysis } withTests: { AuxiliarClassForMutationTestingAnalysisTest }. numberOfMutations := analysis mutations size. @@ -22,7 +22,7 @@ MutationTestingPercentageOfMutantsBudgetTest >> runAnalysisFor: aPercentage [ ] { #category : 'tests' } -MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateAllMutantsWithMoreThanOneHundredPercentConstraint [ +MTPercentageOfMutantsBudgetTest >> testEvaluateAllMutantsWithMoreThanOneHundredPercentConstraint [ self runAnalysisFor: 120. self @@ -32,7 +32,7 @@ MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateAllMutantsWithMoreTh ] { #category : 'tests' } -MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateTheCorrectPercentageOfMutants [ +MTPercentageOfMutantsBudgetTest >> testEvaluateTheCorrectPercentageOfMutants [ self runAnalysisFor: 20. self @@ -42,7 +42,7 @@ MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateTheCorrectPercentage ] { #category : 'tests' } -MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithNegativePercentConstraint [ +MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithNegativePercentConstraint [ self runAnalysisFor: -10. self @@ -52,7 +52,7 @@ MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutants ] { #category : 'tests' } -MutationTestingPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithZeroPercentConstraint [ +MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithZeroPercentConstraint [ self runAnalysisFor: 0. self diff --git a/src/MuTalk-Tests/MutationTestingTimeBudgetTest.class.st b/src/MuTalk-Tests/MTTimeBudgetTest.class.st similarity index 76% rename from src/MuTalk-Tests/MutationTestingTimeBudgetTest.class.st rename to src/MuTalk-Tests/MTTimeBudgetTest.class.st index f3f54925..52d4e2d7 100644 --- a/src/MuTalk-Tests/MutationTestingTimeBudgetTest.class.st +++ b/src/MuTalk-Tests/MTTimeBudgetTest.class.st @@ -1,27 +1,27 @@ Class { - #name : 'MutationTestingTimeBudgetTest', - #superclass : 'MutationTestingBudgetTest', + #name : 'MTTimeBudgetTest', + #superclass : 'MTBudgetTest', #category : 'MuTalk-Tests', #package : 'MuTalk-Tests' } { #category : 'running' } -MutationTestingTimeBudgetTest >> fixedAnalysisTime [ +MTTimeBudgetTest >> fixedAnalysisTime [ ^ [ self runAnalysisFor: 0 seconds ] timeToRun ] { #category : 'running' } -MutationTestingTimeBudgetTest >> runAnalysisFor: aDuration [ +MTTimeBudgetTest >> runAnalysisFor: aDuration [ ^ self - runAnalysisWithBudget: (MutationTestingTimeBudget for: aDuration) - on: { AuxiliarClassForMutationTestingBudget } - withTests: { AuxiliarTestClassForMutationTestingBudget } + runAnalysisWithBudget: (MTTimeBudget for: aDuration) + on: { AuxiliarClassForMTBudget } + withTests: { AuxiliarTestClassForMTBudget } ] { #category : 'running' } -MutationTestingTimeBudgetTest >> runAnalysisWithBudget: aBudget on: classesToMutate withTests: testCases [ +MTTimeBudgetTest >> runAnalysisWithBudget: aBudget on: classesToMutate withTests: testCases [ analysis := MutationTestingAnalysis testCasesFrom: testCases @@ -39,7 +39,7 @@ MutationTestingTimeBudgetTest >> runAnalysisWithBudget: aBudget on: classesToMut ] { #category : 'tests' } -MutationTestingTimeBudgetTest >> testWithNoTimeForMutantsRespectsDeadline [ +MTTimeBudgetTest >> testWithNoTimeForMutantsRespectsDeadline [ | duration analysisTime error fixedAnalysisTime | "Let's run the analysis for so much time that it will run the fixed cost (initial test run, coverage analysis) * N, making sure we will execute some mutants" @@ -53,7 +53,7 @@ MutationTestingTimeBudgetTest >> testWithNoTimeForMutantsRespectsDeadline [ ] { #category : 'tests' } -MutationTestingTimeBudgetTest >> testWithNoTimeForMutantsRunsNoMutants [ +MTTimeBudgetTest >> testWithNoTimeForMutantsRunsNoMutants [ | duration analysisTime result | "Divide duration by 4 to make sure we never have time for mutants" @@ -65,7 +65,7 @@ MutationTestingTimeBudgetTest >> testWithNoTimeForMutantsRunsNoMutants [ ] { #category : 'tests' } -MutationTestingTimeBudgetTest >> testWithTimeForMutantsRespectsDeadline [ +MTTimeBudgetTest >> testWithTimeForMutantsRespectsDeadline [ | duration analysisTime error | "Let's run the analysis for so much time that it will run the fixed cost (initial test run, coverage analysis) * N, making sure we will execute some mutants" @@ -78,7 +78,7 @@ MutationTestingTimeBudgetTest >> testWithTimeForMutantsRespectsDeadline [ ] { #category : 'tests' } -MutationTestingTimeBudgetTest >> testWithTimeForMutantsRunsManyMutants [ +MTTimeBudgetTest >> testWithTimeForMutantsRunsManyMutants [ | duration analysisTime result | "Let's run the analysis for so much time that it will run the fixed cost (initial test run, coverage analysis) * N, making sure we will execute some mutants" diff --git a/src/MuTalk-Tests/TestCasesSelectionStrategyTest.class.st b/src/MuTalk-Tests/TestCasesSelectionStrategyTest.class.st index a7c20e37..8e6d21f7 100644 --- a/src/MuTalk-Tests/TestCasesSelectionStrategyTest.class.st +++ b/src/MuTalk-Tests/TestCasesSelectionStrategyTest.class.st @@ -14,7 +14,7 @@ TestCasesSelectionStrategyTest >> allTestsFromPackage [ with: TestClassForTestingCoverage with: AuxiliarTestClassForTestingStrategies with: AuxiliarClassForMutationTestingAnalysisTest - with: AuxiliarTestClassForMutationTestingBudget) + with: AuxiliarTestClassForMTBudget) inject: OrderedCollection new into: [:tests :testClass | tests addAll: testClass suite tests. From 76328a6141bc5f2d71ba7d4f03912baa04c7bae5 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Fri, 15 Dec 2023 10:10:49 +0100 Subject: [PATCH 2/3] rename check:with: to be more intention revealing --- src/MuTalk-Model/MTBudget.class.st | 13 +++++++------ .../MTFixedNumberOfMutantsBudget.class.st | 2 +- src/MuTalk-Model/MTFreeBudget.class.st | 3 ++- .../MTPercentageOfMutantsBudget.class.st | 2 +- src/MuTalk-Model/MTTimeBudget.class.st | 2 +- src/MuTalk-Model/MutationTestingAnalysis.class.st | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/MuTalk-Model/MTBudget.class.st b/src/MuTalk-Model/MTBudget.class.st index d5940078..3b79322f 100644 --- a/src/MuTalk-Model/MTBudget.class.st +++ b/src/MuTalk-Model/MTBudget.class.st @@ -16,12 +16,6 @@ MTBudget class >> for: aConstraint [ yourself ] -{ #category : 'validation' } -MTBudget >> check: partialCollection with: initialCollection [ - - ^ self subclassResponsibility -] - { #category : 'accessing' } MTBudget >> constraint [ @@ -34,6 +28,13 @@ MTBudget >> constraint: aConstraint [ constraint := aConstraint ] +{ #category : 'validation' } +MTBudget >> exceedBudgetOn: partialCollection considering: initialCollection [ + "Returns true if partialCollection exceed the budget (the time is over, there is enough mutants, etc). Some budgets need data on initialCollection (e.g. percentage budget needs the size)" + + ^ self subclassResponsibility +] + { #category : 'accessing' } MTBudget >> start [ "Does nothing for most budgets because they don't need specific data at the start of the execution of the mutation testing analysis, but some do (time budget for example). diff --git a/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st b/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st index 98a866c4..0dabe799 100644 --- a/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st +++ b/src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st @@ -6,7 +6,7 @@ Class { } { #category : 'validation' } -MTFixedNumberOfMutantsBudget >> check: partialCollection with: initialCollection [ +MTFixedNumberOfMutantsBudget >> exceedBudgetOn: partialCollection considering: initialCollection [ ^ partialCollection size >= constraint ] diff --git a/src/MuTalk-Model/MTFreeBudget.class.st b/src/MuTalk-Model/MTFreeBudget.class.st index 242aee29..c66acf8d 100644 --- a/src/MuTalk-Model/MTFreeBudget.class.st +++ b/src/MuTalk-Model/MTFreeBudget.class.st @@ -6,7 +6,8 @@ Class { } { #category : 'validation' } -MTFreeBudget >> check: partialCollection with: initialCollection [ +MTFreeBudget >> exceedBudgetOn: partialCollection considering: initialCollection [ + "Since this budget have no constraint, the budget is never exceeded" ^ false ] diff --git a/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st b/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st index db5e01ec..21f803b3 100644 --- a/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st +++ b/src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st @@ -6,7 +6,7 @@ Class { } { #category : 'validation' } -MTPercentageOfMutantsBudget >> check: partialCollection with: initialCollection [ +MTPercentageOfMutantsBudget >> exceedBudgetOn: partialCollection considering: initialCollection [ ^ partialCollection size >= (constraint / 100 * initialCollection size) diff --git a/src/MuTalk-Model/MTTimeBudget.class.st b/src/MuTalk-Model/MTTimeBudget.class.st index 7ed0e807..a08b3eda 100644 --- a/src/MuTalk-Model/MTTimeBudget.class.st +++ b/src/MuTalk-Model/MTTimeBudget.class.st @@ -9,7 +9,7 @@ Class { } { #category : 'validation' } -MTTimeBudget >> check: partialCollection with: initialCollection [ +MTTimeBudget >> exceedBudgetOn: partialCollection considering: initialCollection [ | currentTime | currentTime := Time current asMilliSeconds. diff --git a/src/MuTalk-Model/MutationTestingAnalysis.class.st b/src/MuTalk-Model/MutationTestingAnalysis.class.st index 489090b4..f6070019 100644 --- a/src/MuTalk-Model/MutationTestingAnalysis.class.st +++ b/src/MuTalk-Model/MutationTestingAnalysis.class.st @@ -372,7 +372,7 @@ MutationTestingAnalysis >> generateResults [ particularResults := OrderedCollection new. mutations do: [ :aMutation | - (budget check: particularResults with: mutations) ifTrue: [ + (budget exceedBudgetOn: particularResults considering: mutations) ifTrue: [ ^ particularResults ]. logger logStartEvaluating: aMutation. particularResults add: (MutantEvaluation From 38ea1d467422cde132c2cf0ba41654ed837ec5d0 Mon Sep 17 00:00:00 2001 From: Durieux Pol Date: Fri, 15 Dec 2023 15:12:01 +0100 Subject: [PATCH 3/3] merge --- .../MTPercentageOfMutantsBudgetTest.class.st | 27 ++++++++++++----- ...tingPercentageOfMutantsBudgetTest.class.st | 30 ------------------- 2 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st diff --git a/src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st b/src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st index 3419baa2..a55ecfb7 100644 --- a/src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st +++ b/src/MuTalk-Tests/MTPercentageOfMutantsBudgetTest.class.st @@ -32,19 +32,19 @@ MTPercentageOfMutantsBudgetTest >> testEvaluateAllMutantsWithMoreThanOneHundredP ] { #category : 'tests' } -MTPercentageOfMutantsBudgetTest >> testEvaluateTheCorrectPercentageOfMutants [ +MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithNegativePercentConstraint [ - self runAnalysisFor: 20. + self runAnalysisFor: -10. self assert: analysis generalResult numberOfEvaluatedMutants / numberOfMutations * 100 - equals: 20 + equals: 0 ] { #category : 'tests' } -MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithNegativePercentConstraint [ +MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithZeroPercentConstraint [ - self runAnalysisFor: -10. + self runAnalysisFor: 0. self assert: analysis generalResult numberOfEvaluatedMutants / numberOfMutations * 100 @@ -52,11 +52,22 @@ MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithNegativeP ] { #category : 'tests' } -MTPercentageOfMutantsBudgetTest >> testEvaluateZeroPercentOfMutantsWithZeroPercentConstraint [ +MTPercentageOfMutantsBudgetTest >> testExactPercentageOfMutants [ - self runAnalysisFor: 0. + self runAnalysisFor: 20. self assert: analysis generalResult numberOfEvaluatedMutants / numberOfMutations * 100 - equals: 0 + equals: 20 +] + +{ #category : 'tests' } +MTPercentageOfMutantsBudgetTest >> testNonExactPercentageOfMutants [ + + self runAnalysisFor: 21. + self assert: + analysis generalResult numberOfEvaluatedMutants / numberOfMutations * 100 >= 21. + self + assert: analysis generalResult numberOfEvaluatedMutants + equals: 6 ] diff --git a/src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st b/src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st deleted file mode 100644 index 15d4bc73..00000000 --- a/src/MuTalk-Tests/MutationTestingPercentageOfMutantsBudgetTest.class.st +++ /dev/null @@ -1,30 +0,0 @@ -Class { - #name : 'MutationTestingPercentageOfMutantsBudgetTest', - #superclass : 'MutationTestingBudgetTest', - #instVars : [ - 'numberOfMutations' - ], - #category : 'MuTalk-Tests', - #package : 'MuTalk-Tests' -} - -{ #category : 'tests' } -MutationTestingPercentageOfMutantsBudgetTest >> testExactPercentageOfMutants [ - - self runAnalysisFor: 20. - self - assert: - analysis generalResult numberOfEvaluatedMutants / numberOfMutations * 100 - equals: 20 -] - -{ #category : 'tests' } -MutationTestingPercentageOfMutantsBudgetTest >> testNonExactPercentageOfMutants [ - - self runAnalysisFor: 21. - self assert: - analysis generalResult numberOfEvaluatedMutants / numberOfMutations * 100 >= 21. - self - assert: analysis generalResult numberOfEvaluatedMutants - equals: 6 -]