diff --git a/src/Famix-UnitTest-Exporter/FamixUTSUnitAssertionStrategy.class.st b/src/Famix-UnitTest-Exporter/FamixUTSUnitAssertionStrategy.class.st index 5667b38..68e4f86 100644 --- a/src/Famix-UnitTest-Exporter/FamixUTSUnitAssertionStrategy.class.st +++ b/src/Famix-UnitTest-Exporter/FamixUTSUnitAssertionStrategy.class.st @@ -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: diff --git a/src/Famix-UnitTest-Exporter/FamixUTSUnitExporter.class.st b/src/Famix-UnitTest-Exporter/FamixUTSUnitExporter.class.st index c17aa82..c75a2f8 100644 --- a/src/Famix-UnitTest-Exporter/FamixUTSUnitExporter.class.st +++ b/src/Famix-UnitTest-Exporter/FamixUTSUnitExporter.class.st @@ -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" @@ -34,6 +45,14 @@ 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) ] @@ -41,11 +60,11 @@ FamixUTSUnitExporter >> exportAssertion: aFamixUTAssertion [ { #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: @@ -53,7 +72,7 @@ FamixUTSUnitExporter >> exportCase: aFamixUTCase [ currentClass := self class classInstaller make: [ :aBuilder | aBuilder - name: aFamixUTCase name; + name: name; superclass: TestCase; package: (self newTestClassCategoryFor: @@ -91,7 +110,7 @@ FamixUTSUnitExporter >> exportMethod: aFamixUTMethod [ aFamixUTMethod tearDown ifNotNil: [ :tearDown | self exportMethodTearDown: tearDown ]. - ^ self makeTestMethod: aFamixUTMethod. + ^ self makeTestMethod: aFamixUTMethod ] { #category : #exporting }