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

Add heatmap to MTMatrix #79

Merged
merged 6 commits into from
Feb 15, 2024
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
6 changes: 6 additions & 0 deletions src/MuTalk-Model/MTTestCaseReference.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ MTTestCaseReference >> method [
^ class >> selector
]

{ #category : 'printing' }
MTTestCaseReference >> printOn: aStream [

aStream nextPutAll: (aStream print: self testCase)
]

{ #category : 'evaluating' }
MTTestCaseReference >> resources [
^self testCase resources
Expand Down
69 changes: 69 additions & 0 deletions src/MuTalk-Utilities/MTMatrix.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,36 @@ MTMatrix >> classesToMutate: aClass [
classesToMutate := aClass
]

{ #category : 'computing' }
MTMatrix >> dataForTests: testCollection andMutations: mutationCollection [

| totalNumberOfTestsExecuted numberOfFailuresCollection totalNumberOfFailures |
totalNumberOfTestsExecuted := testCollection size
* mutationCollection size.
numberOfFailuresCollection := mutationCollection collect: [ :mutation |
| testClass |
"We know that all tests from testCollection are from the same class"
testClass := testCollection atRandom
testCaseClass.
(self
failuresFor: mutation
andTestClass: testClass) size ].
totalNumberOfFailures := numberOfFailuresCollection fold: [ :num1 :num2 |
num1 + num2 ].
^ (totalNumberOfFailures / totalNumberOfTestsExecuted * 100)
asInteger
]

{ #category : 'computing' }
MTMatrix >> dataMatrixForTests: testDictionary andMutations: mutationDictionary [

^ mutationDictionary values collect: [ :mutationCollection |
testDictionary values collect: [ :testCollection |
self
dataForTests: testCollection
andMutations: mutationCollection ] ]
]

{ #category : 'accessing' }
MTMatrix >> equivalentMutants [

Expand Down Expand Up @@ -158,6 +188,32 @@ MTMatrix >> failuresFor: aMutant [
MTTestCaseReference for: each selector in: each class ]
]

{ #category : 'computing' }
MTMatrix >> failuresFor: aMutation andTestClass: aTestClass [

^ (self failuresFor: aMutation) select: [ :testCase |
testCase testCaseClass = aTestClass ]
]

{ #category : 'rendering' }
MTMatrix >> generateHeatmap [

| heatmap mutationDictionary testDictionary |
mutationDictionary := mutations groupedBy: [ :mutation |
mutation operator species ].
testDictionary := testCases groupedBy: #testCaseClass.

heatmap := self initializeHeatmap.

heatmap objectsX: testClasses.
heatmap objectsY: mutationDictionary keys.
heatmap dataMatrix: (self
dataMatrixForTests: testDictionary
andMutations: mutationDictionary).

heatmap open
]

{ #category : 'rendering' }
MTMatrix >> generateMatrix [

Expand All @@ -181,6 +237,19 @@ MTMatrix >> includedMutants [
^ includedMutants
]

{ #category : 'initialization' }
MTMatrix >> initializeHeatmap [

| heatmap |
heatmap := RSHeatmap new.
heatmap labelShapeCell labelShape bold.
heatmap shape extent: 50 @ 20.
heatmap colorPalette: (NSScale linear range: {
Color yellow.
Color red }).
^ heatmap
]

{ #category : 'comparing' }
MTMatrix >> mutant1: mutant1 equalsMutant2: mutant2 [

Expand Down
Loading