Skip to content

Commit

Permalink
Merge a28a848
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed May 17, 2024
2 parents b21359e + a28a848 commit ea9242d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
23 changes: 23 additions & 0 deletions src/Famix-UnitTest-Exporter/FamixUTSUnitAssertionStrategy.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,29 @@ Class {
{ #category : #exporting }
FamixUTSUnitAssertionStrategy >> export: aFamixUTAssertion on: exporter [

^ aFamixUTAssertion expected resultInSpan tags
at: 'error'
ifPresent: [ :error |
self export: aFamixUTAssertion shouldRaise: error on: exporter ]
ifAbsent: [
self exportAssertEquals: aFamixUTAssertion on: exporter ]
]

{ #category : #exporting }
FamixUTSUnitAssertionStrategy >> export: aFamixUTAssertion shouldRaise: error on: exporter [

^ RBMessageNode
receiver: (RBVariableNode named: 'self')
selector: #should:raise:
arguments: {
(RBVariableNode named: 'actual').
(RBVariableNode named:
(error copyFrom: 1 to: (error indexOf: $:) - 1)) }
]

{ #category : #exporting }
FamixUTSUnitAssertionStrategy >> exportAssertEquals: aFamixUTAssertion on: exporter [

^ RBMessageNode
receiver: (RBVariableNode named: 'self')
selector: #assert:equals:
Expand Down
29 changes: 24 additions & 5 deletions src/Famix-UnitTest-Exporter/FamixUTSUnitExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ FamixUTSUnitExporter >> addNewCommentForTestClass: aClass basedOn: baseClass [
nextPutAll: baseClass name ])
]

{ #category : #exporting }
FamixUTSUnitExporter >> export: aFamixUTModel [

(aFamixUTModel allWithType: FamixUTCase) do: [ :case |
self exportCaseFile: case ].
(aFamixUTModel allWithType: FamixUTSuite) do: [ :suite |
self exportSuite: suite ].
self valueExporter makeHelper.
^ self model
]

{ #category : #exporting }
FamixUTSUnitExporter >> exportAct: aFamixUTAct [
"Execute the method under test"
Expand All @@ -34,26 +45,34 @@ FamixUTSUnitExporter >> exportAct: aFamixUTAct [
{ #category : #exporting }
FamixUTSUnitExporter >> exportAssertion: aFamixUTAssertion [

aFamixUTAssertion expected resultInSpan tags
at: 'error'
ifPresent: [
| actualBlock block |
actualBlock := self statementBlock children last.
block := RBBlockNode body:
(RBSequenceNode statements: { actualBlock value }).
actualBlock replaceNode: actualBlock value withNode: block ].
^ self statementBlock addNode:
(self assertionStrategy export: aFamixUTAssertion on: self)
]

{ #category : #exporting }
FamixUTSUnitExporter >> exportCase: aFamixUTCase [

| currentClass systemEnvironment |
"créer package ou vérifier qu'il existe (testClassFor: inputClass)"
| currentClass systemEnvironment name |
name := aFamixUTCase testedClass name , 'ModestTest'.
systemEnvironment := ClySystemEnvironment currentImage.
systemEnvironment
classNamed: aFamixUTCase name
classNamed: name
ifPresent: [ :class | currentClass := class ]
ifAbsent: [
systemEnvironment ensureExistAndRegisterPackageNamed:
aFamixUTCase testedClass parentPackage name asString , '-Tests'.

currentClass := self class classInstaller make: [ :aBuilder |
aBuilder
name: aFamixUTCase name;
name: name;
superclass: TestCase;
package:
(self newTestClassCategoryFor:
Expand Down Expand Up @@ -91,7 +110,7 @@ FamixUTSUnitExporter >> exportMethod: aFamixUTMethod [
aFamixUTMethod tearDown ifNotNil: [ :tearDown |
self exportMethodTearDown: tearDown ].

^ self makeTestMethod: aFamixUTMethod.
^ self makeTestMethod: aFamixUTMethod
]

{ #category : #exporting }
Expand Down

0 comments on commit ea9242d

Please sign in to comment.