Skip to content
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

Refactored and renamed classes and methods for budgets #48

Merged
merged 4 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/MuTalk-Model/MTBudget.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
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 : 'accessing' }
MTBudget >> constraint [

^ constraint
]

{ #category : 'accessing' }
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).
In this case, this method should be overriden."


]
12 changes: 12 additions & 0 deletions src/MuTalk-Model/MTFixedNumberOfMutantsBudget.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Class {
#name : 'MTFixedNumberOfMutantsBudget',
#superclass : 'MTBudget',
#category : 'MuTalk-Model',
#package : 'MuTalk-Model'
}

{ #category : 'validation' }
MTFixedNumberOfMutantsBudget >> exceedBudgetOn: partialCollection considering: initialCollection [

^ partialCollection size >= constraint
]
13 changes: 13 additions & 0 deletions src/MuTalk-Model/MTFreeBudget.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Class {
#name : 'MTFreeBudget',
#superclass : 'MTBudget',
#category : 'MuTalk-Model',
#package : 'MuTalk-Model'
}

{ #category : 'validation' }
MTFreeBudget >> exceedBudgetOn: partialCollection considering: initialCollection [
"Since this budget have no constraint, the budget is never exceeded"

^ false
]
13 changes: 13 additions & 0 deletions src/MuTalk-Model/MTPercentageOfMutantsBudget.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Class {
#name : 'MTPercentageOfMutantsBudget',
#superclass : 'MTBudget',
#category : 'MuTalk-Model',
#package : 'MuTalk-Model'
}

{ #category : 'validation' }
MTPercentageOfMutantsBudget >> exceedBudgetOn: partialCollection considering: initialCollection [

^ partialCollection size
>= (constraint / 100 * initialCollection size)
]
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Class {
#name : 'MutationTestingTimeBudget',
#superclass : 'MutationTestingBudget',
#name : 'MTTimeBudget',
#superclass : 'MTBudget',
#instVars : [
'initialTime'
],
Expand All @@ -9,15 +9,15 @@ Class {
}

{ #category : 'validation' }
MutationTestingTimeBudget >> check: partialCollection with: initialCollection [
MTTimeBudget >> exceedBudgetOn: partialCollection considering: initialCollection [

| currentTime |
currentTime := Time current asMilliSeconds.
^ currentTime - initialTime >= constraint asMilliSeconds
]

{ #category : 'accessing' }
MutationTestingTimeBudget >> start [
MTTimeBudget >> start [

initialTime := Time current asMilliSeconds
]
4 changes: 2 additions & 2 deletions src/MuTalk-Model/MutationTestingAnalysis.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ MutationTestingAnalysis class >> defaultMutantsEvaluationStrategy [
{ #category : 'defaults' }
MutationTestingAnalysis class >> defaultMutationTestingBudget [

^ MutationTestingFreeBudget new
^ MTFreeBudget new
]

{ #category : 'defaults' }
Expand Down Expand Up @@ -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
Expand Down
41 changes: 0 additions & 41 deletions src/MuTalk-Model/MutationTestingBudget.class.st

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions src/MuTalk-Model/MutationTestingFreeBudget.class.st

This file was deleted.

19 changes: 0 additions & 19 deletions src/MuTalk-Model/MutationTestingPercentageOfMutantsBudget.class.st

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
Class {
#name : 'AuxiliarClassForMutationTestingBudget',
#name : 'AuxiliarClassForMTBudget',
#superclass : 'Object',
#category : 'MuTalk-TestResources',
#package : 'MuTalk-TestResources'
}

{ #category : 'arithmetic' }
AuxiliarClassForMutationTestingBudget >> nil [
AuxiliarClassForMTBudget >> nil [

^ nil
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : 'AuxiliarTestClassForMutationTestingBudget',
#name : 'AuxiliarTestClassForMTBudget',
#superclass : 'TestCase',
#instVars : [
'object'
Expand All @@ -9,7 +9,7 @@ Class {
}

{ #category : 'tests' }
AuxiliarTestClassForMutationTestingBudget >> testNil [
AuxiliarTestClassForMTBudget >> testNil [


]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Class {
#name : 'MutationTestingBudgetTest',
#name : 'MTBudgetTest',
#superclass : 'TestCase',
#instVars : [
'analysis'
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -24,7 +24,7 @@ MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateAllMutantsWithConst
]

{ #category : 'tests' }
MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateTheCorrectNumberOfMutants [
MTFixedNumberOfMutantsBudgetTest >> testEvaluateTheCorrectNumberOfMutants [

self runAnalysisFor: 10.
self
Expand All @@ -33,7 +33,7 @@ MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateTheCorrectNumberOfM
]

{ #category : 'tests' }
MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithConstraintOfZero [
MTFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithConstraintOfZero [

self runAnalysisFor: 0.
self
Expand All @@ -42,7 +42,7 @@ MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithCons
]

{ #category : 'tests' }
MutationTestingFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithNegativeConstraint [
MTFixedNumberOfMutantsBudgetTest >> testEvaluateZeroMutantsWithNegativeConstraint [

self runAnalysisFor: -10.
self
Expand Down
Loading
Loading