Skip to content

Commit

Permalink
- Add some not super nice tests on reporter.
Browse files Browse the repository at this point in the history
- Enhance robustness of results that would be missing information (added dummy initialize methods).
  • Loading branch information
Ducasse committed Sep 11, 2024
1 parent 5dfe5a6 commit 1023015
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Class {
#name : 'MicAnalysisReportWriterTest',
#superclass : 'TestCase',
#category : 'Microdown-BookTester-Tests',
#package : 'Microdown-BookTester-Tests'
}

{ #category : 'tests' }
MicAnalysisReportWriterTest >> testWithEmptyResults [

self assert: MicAnalysisReportWriter new report isEmpty
]

{ #category : 'tests' }
MicAnalysisReportWriterTest >> testWithResults [

| reporter |
reporter := MicAnalysisReportWriter new
addResults: { MicBrokenSyncDefinition new };
addResults: { MicBrokenSyncOriginDefinition new }.
self assert: reporter results size equals: 2.
self deny: reporter report isEmpty
]
36 changes: 36 additions & 0 deletions src/Microdown-BookTester-Tests/MicResultTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,42 @@ MicResultTest >> testExplanationUndefinedAnchor [

]

{ #category : 'tests - basic result creation' }
MicResultTest >> testMicBookTestResultExplanationWorksWithEmptyInstance [

self flag: #improve.
"I do not like these tests that test string."
self
assert: MicBookTestResult new explanation
equals: 'test status: Passed
isExpectedFailure? false
Description of the test result : Test failed without raising an exception
the concerned code Block : here we should get an expression
from the source file: nil'
]

{ #category : 'tests - basic result creation' }
MicResultTest >> testMicBrokenSyncDefinitionResultExplanationWorksWithEmptyInstance [

self flag: #improve.
"I do not like these tests that test string."
self
assert: MicBrokenSyncDefinition new explanation
equals: 'The sync definition has the following broken value: empty .'
]

{ #category : 'tests - basic result creation' }
MicResultTest >> testResultCreation [

{ MicBookTestResult . MicBrokenSyncDefinition . MicBrokenSyncOriginDefinition . MicDesynchronizedCodeResult . MicDuplicatedAnchorResult . MicUndefinedAnchorResult . MicUndefinedFigureFileResult . MicUndefinedInputFileResult} do: [ :each | each new printString ]
]

{ #category : 'tests - basic result creation' }
MicResultTest >> testResultCreationSmokeTest [

{ MicBookTestResult . MicBrokenSyncDefinition . MicBrokenSyncOriginDefinition . MicDesynchronizedCodeResult . MicDuplicatedAnchorResult . MicUndefinedAnchorResult . MicUndefinedFigureFileResult . MicUndefinedInputFileResult} do: [ :each | each new printString ]
]

{ #category : 'tests' }
MicResultTest >> testSTONFormatExplanationDuplicatedAnchor [

Expand Down
12 changes: 10 additions & 2 deletions src/Microdown-BookTester/MicAnalysisReportWriter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ MicAnalysisReportWriter >> buildReportSTONFormatOn: str [
list := OrderedCollection new.
self reportElementsSTONFormatOn: list.
list := list asArray.
array at: 1 put: (Association new key: 'type' value: k errorType);
at: 2 put: list.
array
at: 1 put: (Association new key: 'type' value: k errorType);
at: 2 put: list.
(String streamContents: [ :out | STON put: array onStream: str ])
]
]

{ #category : 'initialization' }
MicAnalysisReportWriter >> initialize [

super initialize.
results := OrderedCollection new
]

{ #category : 'reporting' }
MicAnalysisReportWriter >> report [

Expand Down
5 changes: 3 additions & 2 deletions src/Microdown-BookTester/MicBookTestResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ MicBookTestResult >> initialize [

super initialize.
status := true.
isExpectedFailure := false .
message := 'Test failed without raising an exception'
isExpectedFailure := false.
message := 'Test failed without raising an exception'.
text := 'here we should get an expression'
]

{ #category : 'accessing' }
Expand Down
13 changes: 13 additions & 0 deletions src/Microdown-BookTester/MicBrokenSyncDefinition.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicBrokenSyncDefinition class >> headerString [

^ 'Broken sync definition [should be sync=''true|false'''
]

{ #category : 'building' }
MicBrokenSyncDefinition >> codeBlock: aMicCodeBlock [
codeBlock := aMicCodeBlock
Expand All @@ -29,6 +35,13 @@ MicBrokenSyncDefinition >> explanation [
^ 'The sync definition has the following broken value: ', syncValue, ' .'
]

{ #category : 'initialization' }
MicBrokenSyncDefinition >> initialize [

super initialize.
syncValue := 'empty'
]

{ #category : 'accessing' }
MicBrokenSyncDefinition >> syncValue [
^ syncValue
Expand Down
18 changes: 18 additions & 0 deletions src/Microdown-BookTester/MicBrokenSyncOriginDefinition.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,24 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'kinds' }
MicBrokenSyncOriginDefinition class >> headerString [

^ 'Broken sync origin specification [ should be C [class]>>#selector ]'
]

{ #category : 'accessing' }
MicBrokenSyncOriginDefinition >> explanation [

^ 'The sync origin in the definition is bogus it should be C [class]>> #selector and we get: ', origin
]

{ #category : 'accessing' }
MicBrokenSyncOriginDefinition >> initialize [
super initialize.
origin := 'C [class]>>#selector'
]

{ #category : 'accessing' }
MicBrokenSyncOriginDefinition >> originString: aString [
origin := aString
Expand Down
18 changes: 15 additions & 3 deletions src/Microdown-BookTester/MicDesynchronizedCodeResult.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ Class {
#package : 'Microdown-BookTester'
}

{ #category : 'accessing' }
MicDesynchronizedCodeResult >> bookContent [
^ bookContents
{ #category : 'kinds' }
MicDesynchronizedCodeResult class >> headerString [

^ 'Desynchronized method body'
]

{ #category : 'accessing' }
Expand Down Expand Up @@ -45,6 +46,17 @@ MicDesynchronizedCodeResult >> imageContents [
^ imageContents
]

{ #category : 'initialization' }
MicDesynchronizedCodeResult >> initialize [

super initialize.
bookContents := 'book contents'.
imageContents := 'image contents'.
originString := 'C [class]>>#selector'.
pharoVersion := '>12'

]

{ #category : 'accessing' }
MicDesynchronizedCodeResult >> originString [
^ originString
Expand Down

0 comments on commit 1023015

Please sign in to comment.