Skip to content

Commit

Permalink
added heatmap
Browse files Browse the repository at this point in the history
  • Loading branch information
Durieux Pol committed Feb 15, 2024
1 parent 2e3ec99 commit 4bcfc5e
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
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
55 changes: 55 additions & 0 deletions src/MuTalk-Utilities/MTMatrix.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,33 @@ MTMatrix >> classesToMutate: aClass [
classesToMutate := aClass
]

{ #category : 'as yet unclassified' }
MTMatrix >> dataForTests: testCollection andMutations: mutationCollection [

| totalNumberOfTests numberOfFailuresCollection killedCount |
totalNumberOfTests := testCollection size * mutationCollection size.
numberOfFailuresCollection := mutationCollection collect: [ :mutation |
((self failuresFor: mutation) select: [
:testCase |
testCase testCaseClass
=
(testCollection at: 1) testCaseClass ])
size ].
killedCount := numberOfFailuresCollection fold: [ :num1 :num2 |
num1 + num2 ].
^ (killedCount / totalNumberOfTests * 100) asInteger
]

{ #category : 'as yet unclassified' }
MTMatrix >> dataMatrixForTests: testDictionary andMutations: mutationDictionary [

^ (mutationDictionary collect: [ :mutationCollection |
(testDictionary collect: [ :testCollection |
self
dataForTests: testCollection
andMutations: mutationCollection ]) asArray ]) asArray
]

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

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

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

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

heatmap := RSHeatmap new.
heatmap colorPalette: (NSScale linear range: {
Color gray.
Color purple muchDarker }).
heatmap labelShapeCell labelShape
border: (RSBorder new
color: Color black;
width: 0.2);
color: Color white.
heatmap shape extent: 50 @ 20.

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

heatmap open
]

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

Expand Down

0 comments on commit 4bcfc5e

Please sign in to comment.