@@ -15,7 +15,6 @@ import org.utbot.framework.codegen.model.constructor.context.CgContextOwner
15
15
import org.utbot.framework.codegen.model.constructor.util.CgComponents
16
16
import org.utbot.framework.codegen.model.constructor.util.classCgClassId
17
17
import org.utbot.framework.codegen.model.constructor.util.importIfNeeded
18
- import org.utbot.framework.codegen.model.tree.CgCommentedAnnotation
19
18
import org.utbot.framework.codegen.model.tree.CgEnumConstantAccess
20
19
import org.utbot.framework.codegen.model.tree.CgExpression
21
20
import org.utbot.framework.codegen.model.tree.CgGetJavaClass
@@ -174,13 +173,39 @@ internal abstract class TestFrameworkManager(val context: CgContext)
174
173
}
175
174
}
176
175
176
+ /* *
177
+ * Supplements TestNG @Test annotation with a description.
178
+ * It looks like @Test(description="...")
179
+ *
180
+ * Should be used only with TestNG.
181
+ * @see <a href="https://github.com/UnitTestBot/UTBotJava/issues/576">issue-576 on GitHub</a>
182
+ */
183
+ open fun addTestDescription (description : String? ) {
184
+ if (description == null ) return
185
+ val testAnnotation =
186
+ collectedMethodAnnotations.singleOrNull { it.classId == testFramework.testAnnotationId }
187
+
188
+ val descriptionArgument = CgNamedAnnotationArgument (" description" , stringLiteral(description))
189
+ if (testAnnotation is CgMultipleArgsAnnotation ) {
190
+ testAnnotation.arguments + = descriptionArgument
191
+ } else {
192
+ collectedMethodAnnotations + = CgMultipleArgsAnnotation (
193
+ testFramework.testAnnotationId,
194
+ mutableListOf (descriptionArgument)
195
+ )
196
+ }
197
+ }
198
+
177
199
abstract fun disableTestMethod (reason : String )
178
200
179
- // We add a commented JUnit5 DisplayName annotation here by default,
180
- // because other test frameworks do not support such feature.
201
+ /* *
202
+ * Adds @DisplayName annotation.
203
+ *
204
+ * Should be used only with JUnit 5.
205
+ * @see <a href="https://github.com/UnitTestBot/UTBotJava/issues/576">issue-576 on GitHub</a>
206
+ */
181
207
open fun addDisplayName (name : String ) {
182
- val displayName = CgSingleArgAnnotation (Junit5 .displayNameClassId, stringLiteral(name))
183
- collectedMethodAnnotations + = CgCommentedAnnotation (displayName)
208
+ collectedMethodAnnotations + = CgSingleArgAnnotation (Junit5 .displayNameClassId, stringLiteral(name))
184
209
}
185
210
186
211
protected fun ClassId.toExceptionClass (): CgExpression =
0 commit comments