Skip to content

Commit

Permalink
Merge pull request #46 from DurieuxPol/fix/issues
Browse files Browse the repository at this point in the history
Improvements to RandomMutantSelectionStrategyTest
  • Loading branch information
guillep authored Dec 15, 2023
2 parents df45cc4 + ccc79a7 commit e42f5ec
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 56 deletions.
26 changes: 26 additions & 0 deletions src/MuTalk-Model/MethodMutation.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ MethodMutation class >> for: aMethod using: anOperatorApplied nodeNumber: aNodeN
yourself
]

{ #category : 'comparing' }
MethodMutation >> = anObject [
"Two method mutations are equals if they have the same operator,if they mutate the same method from the same class, and if they have the same node number"

self == anObject ifTrue: [ ^ true ].
anObject species = self class ifFalse: [ ^ false ].
self operator species = anObject operator species ifFalse: [ ^ false ].
self originalMethod = anObject originalMethod ifFalse: [ ^ false ].
self originalClass = anObject originalClass ifFalse: [ ^ false ].
self nodeNumber = anObject nodeNumber ifFalse: [ ^ false ].
^ true
]

{ #category : 'comparing' }
MethodMutation >> hash [

^ self operator species hash + self originalMethod hash
+ self originalClass hash + self nodeNumber hash
]

{ #category : 'initialize-release' }
MethodMutation >> initializeFor: aMethod using: anOperatorApplied nodeNumber: aNodeNumber ofClass: aClass [
originalMethod := aMethod.
Expand Down Expand Up @@ -53,6 +73,12 @@ MethodMutation >> mutatedNode [
^ operator applyTo: self nodeToMutate
]

{ #category : 'accessing' }
MethodMutation >> nodeNumber [

^ nodeNumber
]

{ #category : 'accessing' }
MethodMutation >> nodeNumber: anInteger [
nodeNumber := anInteger
Expand Down
43 changes: 43 additions & 0 deletions src/MuTalk-Tests/RandomMutantSelectionStrategyTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Class {
#name : 'RandomMutantSelectionStrategyTest',
#superclass : 'TestCase',
#category : 'MuTalk-Tests',
#package : 'MuTalk-Tests'
}

{ #category : 'accessing' }
RandomMutantSelectionStrategyTest >> classToTest [

^ RandomMutantSelectionStrategy
]

{ #category : 'tests' }
RandomMutantSelectionStrategyTest >> testAtLeastTwoDifferentMutantCollectionsAmongFive [
"This test is to ensure that RandomMutantSelectionStrategy doesn't always produce the same mutant collections.
If it can produce at least two different collections, we assume it correctly randomize the inital mutant collection.
Here, two mutant collections are differents when their mutants are not in the same order."

| analysis mutationsSet |
"mutationsSet is a set of mutant collections"
mutationsSet := Set new.
1 to: 5 do: [ :i |
analysis := MutationTestingAnalysis
testCasesFrom:
{ AuxiliarClassForMutationTestingAnalysisTest }
mutating: { AuxiliarClassForMutationTestingAnalysis }
using: MutantOperator contents
with: AllTestsMethodsRunningTestSelectionStrategy new
with: self classToTest new.
mutationsSet add: analysis generateMutations ].

"If the size of the set is at least 2, there is at least 2 different mutant collections, so at least 2 different orders of mutants."
self assert: mutationsSet size >= 2
]

{ #category : 'tests' }
RandomMutantSelectionStrategyTest >> testDefaultMutationsGenerationStrategyIsAllMutantSelectionStrategy [

self
assert: self classToTest new mutationsGenerationStrategy species
equals: AllMutantSelectionStrategy new species
]
50 changes: 0 additions & 50 deletions src/MuTalk-Tests/RandomMutantSelectionTest.class.st

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Class {
#name : 'RandomOperatorMutantSelectionStrategyTest',
#superclass : 'RandomMutantSelectionStrategyTest',
#category : 'MuTalk-Tests',
#package : 'MuTalk-Tests'
}

{ #category : 'accessing' }
RandomOperatorMutantSelectionStrategyTest >> classToTest [

^ RandomOperatorMutantSelectionStrategy
]
6 changes: 0 additions & 6 deletions src/MuTalk-Tests/RandomOperatorMutantSelectionTest.class.st

This file was deleted.

0 comments on commit e42f5ec

Please sign in to comment.