@@ -15,7 +15,6 @@ import org.utbot.framework.codegen.model.constructor.context.CgContextOwner
1515import org.utbot.framework.codegen.model.constructor.util.CgComponents
1616import org.utbot.framework.codegen.model.constructor.util.classCgClassId
1717import org.utbot.framework.codegen.model.constructor.util.importIfNeeded
18- import org.utbot.framework.codegen.model.tree.CgCommentedAnnotation
1918import org.utbot.framework.codegen.model.tree.CgEnumConstantAccess
2019import org.utbot.framework.codegen.model.tree.CgExpression
2120import org.utbot.framework.codegen.model.tree.CgGetJavaClass
@@ -174,13 +173,39 @@ internal abstract class TestFrameworkManager(val context: CgContext)
174173 }
175174 }
176175
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+
177199 abstract fun disableTestMethod (reason : String )
178200
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+ */
181207 open fun addDisplayName (name : String ) {
182- val displayName = CgSingleArgAnnotation (Junit5 .displayNameClassId, stringLiteral(name))
183- collectedMethodAnnotations + = CgCommentedAnnotation (displayName)
208+ collectedMethodAnnotations + = CgSingleArgAnnotation (Junit5 .displayNameClassId, stringLiteral(name))
184209 }
185210
186211 protected fun ClassId.toExceptionClass (): CgExpression =
0 commit comments