Skip to content

Commit

Permalink
Merge pull request #33 from jecisc/32-Improve-test-coverage-using-MuT…
Browse files Browse the repository at this point in the history
…alk-mutation-testing

32-Improve-test-coverage-using-MuTalk-mutation-testing
  • Loading branch information
jecisc authored Nov 8, 2019
2 parents 1d6af61 + b30fb32 commit 716cd41
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ SqueakDebug.log
# Metacello-github cache
/github-cache
github-*.zip

**/.DS_STORE
26 changes: 26 additions & 0 deletions scripts/mutationTesting.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Metacello new
githubUser: 'jecisc' project: 'TinyLogger' commitish: 'v1.x.x' path: 'src';
baseline: 'TinyLogger';
load.

Metacello new
baseline: 'MuTalk';
repository: 'github://pavel-krivanek/mutalk/src';
load.

analysis := MutationTestingAnalysis
testCasesFrom: 'TinyLogger-Tests' asPackage definedClasses
mutating: 'TinyLogger' asPackage definedClasses
using: MutantOperator contents
with: AllTestsMethodsRunningMutantEvaluationStrategy new.
analysis run.
alive := analysis generalResult aliveMutants.

browser := GLMTabulator new.
browser
row: #results;
row: #diff.
browser transmit to: #results.
browser transmit to: #diff; from: #results; andShow: [ :a |
a diff display: [ :mutant | {((RBParser parseMethod: (mutant mutant originalSource)) formattedCode) . ((RBParser parseMethod: (mutant mutant modifiedSource)) formattedCode)}] ].
browser openOn: alive.
31 changes: 31 additions & 0 deletions src/TinyLogger-Tests/TinyLoggerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ TinyLoggerTest >> testClearLog [
self assert: (logger fileLoggers noneSatisfy: [ :fileLogger | fileLogger fileReference exists ])
]

{ #category : #test }
TinyLoggerTest >> testCurrentLogger [
self assert: TinyCurrentLogger value isNotNil.
self assert: TinyCurrentLogger value class equals: TinyLogger
]

{ #category : #test }
TinyLoggerTest >> testEnsureFileLogger [
logger removeAllLoggers.
Expand Down Expand Up @@ -160,6 +166,31 @@ TinyLoggerTest >> testExecuteRecordedAs [
stream close ]
]

{ #category : #test }
TinyLoggerTest >> testExecuteRecordedAs2 [
| contents stream |
self skipInPharo6.
logger
timestampFormatBlock: [ :s | s nextPutAll: 'No time' ];
removeAllLoggers;
addStdoutLogger.
stream := '' writeStream.
[ Stdio stub stdout willReturn: stream.
TinyCurrentLogger value: logger during: [ Object new execute: [ 'test' record ] recordedAs: 'This is a new test' ].
contents := Stdio stdout contents asString.

"Ensure we have the right indentation."
self
assert: contents withUnixLineEndings
equals:
'No time : Begin: This is a new test
No time : test
No time : End: This is a new test
' withUnixLineEndings ]
ensure: [ Stdio recoverFromGHMutation.
stream close ]
]

{ #category : #test }
TinyLoggerTest >> testFileLoggers [
logger
Expand Down
10 changes: 0 additions & 10 deletions src/TinyLogger/ManifestTinyLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,3 @@ Class {
#superclass : #PackageManifest,
#category : #'TinyLogger-Manifest'
}

{ #category : #'code-critics' }
ManifestTinyLogger class >> ruleRBCodeCruftLeftInMethodsRuleV1FalsePositive [
^ #(#(#(#RGClassDefinition #(#TinyTranscriptLogger)) #'2018-11-25T02:59:41.364573+01:00') )
]

{ #category : #'code-critics' }
ManifestTinyLogger class >> ruleRBCollectionMessagesToExternalObjectRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#TinyLogger #addLogger: #false)) #'2018-11-25T20:54:01.067573+01:00') #(#(#RGMethodDefinition #(#TinyLogger #removeLogger: #false)) #'2018-11-25T20:54:59.231573+01:00') )
]
2 changes: 2 additions & 0 deletions src/TinyLogger/TinyAbstractLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Class {

{ #category : #testing }
TinyAbstractLogger class >> isAbstract [
<ignoreForCoverage>
^ self = TinyAbstractLogger
]

Expand All @@ -48,5 +49,6 @@ TinyAbstractLogger >> record: aString [

{ #category : #accessing }
TinyAbstractLogger >> timestampFormatBlock [
<ignoreForCoverage>
^ self subclassResponsibility
]
3 changes: 2 additions & 1 deletion src/TinyLogger/TinyFileLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TinyFileLogger class >> for: aLogger named: aString [

{ #category : #accessing }
TinyFileLogger class >> kind [
<ignoreForCoverage>
^ 'file'
]

Expand Down Expand Up @@ -84,7 +85,7 @@ TinyFileLogger >> fileReference [
TinyFileLogger >> fileStreamDo: aBlock [
"For now we re-open the file all the time to avoid problems when we change its image of computer/OS or if the user delete the file. Maybe later we can find a better solution but in any case we should test such weird behaviors."

^ self fileReference
self fileReference
ensureCreateFile;
writeStreamDo: [ :s |
s setToEnd.
Expand Down
3 changes: 2 additions & 1 deletion src/TinyLogger/TinyLeafLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ TinyLeafLogger class >> for: aTinyLogger [

{ #category : #testing }
TinyLeafLogger class >> isAbstract [
<ignoreForCoverage>
^ self = TinyLeafLogger
]

{ #category : #accessing }
TinyLeafLogger class >> kind [
<ignoreForCoverage>
^ self subclassResponsibility
]

Expand All @@ -67,7 +69,6 @@ TinyLeafLogger >> parentLogger [

{ #category : #accessing }
TinyLeafLogger >> parentLogger: aLogger [
parentLogger == aLogger ifTrue: [ ^ self ].
parentLogger := aLogger
]

Expand Down
2 changes: 1 addition & 1 deletion src/TinyLogger/TinyLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ TinyLogger class >> default: anObject [

{ #category : #initialization }
TinyLogger class >> reset [
^ self default: nil
self default: nil
]

{ #category : #'public API' }
Expand Down
1 change: 1 addition & 0 deletions src/TinyLogger/TinyStdoutLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Class {

{ #category : #accessing }
TinyStdoutLogger class >> kind [
<ignoreForCoverage>
^ 'stdout'
]

Expand Down
1 change: 1 addition & 0 deletions src/TinyLogger/TinyTranscriptLogger.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Class {

{ #category : #accessing }
TinyTranscriptLogger class >> kind [
<ignoreForCoverage>
^ 'transcript'
]

Expand Down

0 comments on commit 716cd41

Please sign in to comment.