Skip to content

Commit

Permalink
JUnit Exporter: better handling of annotation imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel-Darbord committed Jan 15, 2024
1 parent c02dd92 commit 62b59b6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/Famix-UnitTest-Exporter/FamixUTJUnit4Exporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ FamixUTJUnit4Exporter >> nameOfAssertionsClass [
^ 'Assert'
]

{ #category : #'as yet unclassified' }
FamixUTJUnit4Exporter >> nameOfBeforeEachAnnotation [

^ 'Before'
]

{ #category : #naming }
FamixUTJUnit4Exporter >> nameOfJUnitPackage [

Expand Down
6 changes: 6 additions & 0 deletions src/Famix-UnitTest-Exporter/FamixUTJUnit5Exporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ FamixUTJUnit5Exporter >> nameOfAssertionsClass [
^ 'Assertions'
]

{ #category : #'as yet unclassified' }
FamixUTJUnit5Exporter >> nameOfBeforeEachAnnotation [

^ 'BeforeEach'
]

{ #category : #naming }
FamixUTJUnit5Exporter >> nameOfJUnitPackage [

Expand Down
16 changes: 13 additions & 3 deletions src/Famix-UnitTest-Exporter/FamixUTJUnitExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ FamixUTJUnitExporter >> exportCaseFile: aFamixUTCase [
FamixUTJUnitExporter >> exportCaseImports: aFamixUTCase [

| imports |
imports := (aFamixUTCase allTypes select: #needsJavaImport)
imports := (aFamixUTCase allTypes select: [ :type |
type needsJavaImport ])
collect: [ :type | self makeImportDeclaration: type ]
as: OrderedCollection.
imports add: (self makeImportDeclaration: aFamixUTCase testedClass).
Expand Down Expand Up @@ -216,11 +217,14 @@ FamixUTJUnitExporter >> makeJUnitImports [
^ {
(self model newImportDeclaration qualifiedName:
(model newQualifiedName name: package , '.Test')).
(self model newImportDeclaration
(model newImportDeclaration
qualifiedName: (model newQualifiedName name:
package , '.' , self nameOfAssertionsClass);
isStatic: true;
isOnDemand: true) }
isOnDemand: true).
(model newImportDeclaration qualifiedName:
(model newQualifiedName name:
package , '.' , self nameOfBeforeEachAnnotation)) }
]

{ #category : #ast }
Expand Down Expand Up @@ -275,6 +279,12 @@ FamixUTJUnitExporter >> nameOfAssertionsClass [
self subclassResponsibility
]

{ #category : #'as yet unclassified' }
FamixUTJUnitExporter >> nameOfBeforeEachAnnotation [

self subclassResponsibility
]

{ #category : #naming }
FamixUTJUnitExporter >> nameOfJUnitPackage [

Expand Down

0 comments on commit 62b59b6

Please sign in to comment.