Skip to content

Commit

Permalink
implemented tests for time budget
Browse files Browse the repository at this point in the history
  • Loading branch information
Durieux Pol committed Dec 4, 2023
1 parent 3f91321 commit d12fd89
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Class {
#name : #AuxiliarClassForMutationTestingBudget,
#superclass : #Object,
#category : #'MuTalk-TestResources'
}

{ #category : #arithmetic }
AuxiliarClassForMutationTestingBudget >> decrement: aNumber [

^ aNumber - 1
]

{ #category : #arithmetic }
AuxiliarClassForMutationTestingBudget >> increment: aNumber [

^ aNumber + 1
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Class {
#name : #AuxiliarTestClassForMutationTestingBudget,
#superclass : #TestCase,
#instVars : [
'object'
],
#category : #'MuTalk-TestResources'
}

{ #category : #running }
AuxiliarTestClassForMutationTestingBudget >> setUp [
super setUp.

object := AuxiliarClassForMutationTestingBudget new.
(Duration seconds: 2) wait
]

{ #category : #tests }
AuxiliarTestClassForMutationTestingBudget >> testDecrement [

self assert: (object decrement: 2) equals: 1
]

{ #category : #tests }
AuxiliarTestClassForMutationTestingBudget >> testIncrement [

self assert: (object increment: 1) equals: 2
]
5 changes: 5 additions & 0 deletions src/MuTalk-Tests/MutationTestingBudgetTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Class {
#name : #MutationTestingBudgetTest,
#superclass : #TestCase,
#category : #'MuTalk-Tests'
}
59 changes: 59 additions & 0 deletions src/MuTalk-Tests/MutationTestingTimeBudgetTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
Class {
#name : #MutationTestingTimeBudgetTest,
#superclass : #TestCase,
#instVars : [
'budget',
'analysis'
],
#category : #'MuTalk-Tests'
}

{ #category : #running }
MutationTestingTimeBudgetTest >> setUp [

| testCases classesToMutate |
super setUp.

testCases := { AuxiliarTestClassForMutationTestingBudget }.
classesToMutate := { AuxiliarClassForMutationTestingBudget }.

budget := MutationTestingTimeBudget new.

analysis := MutationTestingAnalysis
testCasesFrom: testCases
mutating: classesToMutate
using: MutantOperator contents
with: AllTestsMethodsRunningTestSelectionStrategy new
with: AllMutantSelectionStrategy new
budget: budget
]

{ #category : #tests }
MutationTestingTimeBudgetTest >> test12SecShouldEvaluate2Mutants [

budget constraint: (Duration seconds: 12).
analysis run.
self
assert: analysis generalResult numberOfEvaluatedMutants
equals: 2
]

{ #category : #tests }
MutationTestingTimeBudgetTest >> test13SecShouldEvaluate3Mutants [

budget constraint: (Duration seconds: 13).
analysis run.
self
assert: analysis generalResult numberOfEvaluatedMutants
equals: 3
]

{ #category : #tests }
MutationTestingTimeBudgetTest >> test30SecShouldEvaluate4Mutants [

budget constraint: (Duration seconds: 30).
analysis run.
self
assert: analysis generalResult numberOfEvaluatedMutants
equals: 4
]

0 comments on commit d12fd89

Please sign in to comment.