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

Improvements to RandomMutantSelectionStrategyTest #46

Merged
merged 9 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
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'
}
guillep marked this conversation as resolved.
Show resolved Hide resolved

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

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

This file was deleted.

Loading