-
Notifications
You must be signed in to change notification settings - Fork 45
Generate DisplayName annotation only for JUnit 5 #576 #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1599,7 +1599,23 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c | |
} else { | ||
setOf(annotation(testFramework.testAnnotationId)) | ||
} | ||
displayName?.let { testFrameworkManager.addDisplayName(it) } | ||
|
||
/* Add a short test's description depending on the test framework type: | ||
DisplayName in case of JUni5, and description argument to Test annotation in case of TestNG. | ||
*/ | ||
if (displayName != null) { | ||
when (testFramework) { | ||
is Junit5 -> { | ||
displayName.let { testFrameworkManager.addDisplayName(it) } | ||
} | ||
is TestNg -> { | ||
testFrameworkManager.addTestDescription(displayName) | ||
} | ||
else -> { | ||
// nothing | ||
} | ||
} | ||
} | ||
|
||
val result = currentExecution!!.result | ||
if (result is UtTimeoutException) { | ||
|
@@ -1645,12 +1661,19 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c | |
} | ||
} | ||
|
||
documentation = CgDocumentationComment(docComment) | ||
documentation = if (parameterized) { | ||
val documentationComment = if (parameterized) { | ||
CgDocumentationComment(text = null) | ||
} else { | ||
CgDocumentationComment(docComment) | ||
} | ||
documentation.add(documentationComment) | ||
|
||
/* JUnit4 doesn't have DisplayName annotation and any other suitable for putting short description, | ||
that's why we add a single line comment below JavaDoc with a test's short description. | ||
*/ | ||
if (testFramework is Junit4 && displayName != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably we don't need this short commented summary under the test, it looks weird and clashes with the JavaDocs There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that single-line comment below JavaDoc might look weird, but it contains short useful information about the test. As you suggested in another comment, we can add a custom JavaDoc tag for it in future. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, that the comment line does not look good. I am even not sure, that an average user will understand what it is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed as discussed, now we don't show display name in case of JUnit4. |
||
documentation.add(CgSingleLineComment(displayName)) | ||
} | ||
} | ||
testMethods += testMethod | ||
return testMethod | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to create a ticket to add a custom Java tag for display name as @DisplayName or @summary for JUnit 4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's weird that we just forget the generated display name :( for JUnit4 but generates it.
No logging in this file at all, it's sad too