@@ -3,12 +3,14 @@ package org.utbot.framework.codegen
33import org.utbot.framework.DEFAULT_CONCRETE_EXECUTION_TIMEOUT_IN_CHILD_PROCESS_MS
44import org.utbot.framework.codegen.model.constructor.builtin.mockitoClassId
55import org.utbot.framework.codegen.model.constructor.builtin.ongoingStubbingClassId
6+ import org.utbot.framework.codegen.model.constructor.util.argumentsClassId
67import org.utbot.framework.codegen.model.tree.CgClassId
78import org.utbot.framework.plugin.api.BuiltinClassId
89import org.utbot.framework.plugin.api.ClassId
910import org.utbot.framework.plugin.api.CodeGenerationSettingBox
1011import org.utbot.framework.plugin.api.CodeGenerationSettingItem
1112import org.utbot.framework.plugin.api.MethodId
13+ import org.utbot.framework.plugin.api.TypeParameters
1214import org.utbot.framework.plugin.api.isolateCommandLineArgumentsToArgumentFile
1315import org.utbot.framework.plugin.api.util.booleanArrayClassId
1416import org.utbot.framework.plugin.api.util.booleanClassId
@@ -28,6 +30,7 @@ import org.utbot.framework.plugin.api.util.shortArrayClassId
2830import org.utbot.framework.plugin.api.util.voidClassId
2931import java.io.File
3032import org.utbot.framework.plugin.api.util.longClassId
33+ import org.utbot.framework.plugin.api.util.objectArrayClassId
3134import org.utbot.framework.plugin.api.util.voidWrapperClassId
3235
3336data class TestClassFile (val packageName : String , val imports : List <Import >, val testClass : String )
@@ -183,6 +186,8 @@ sealed class TestFramework(
183186 abstract val methodSourceAnnotation: String
184187 abstract val methodSourceAnnotationId: ClassId
185188 abstract val methodSourceAnnotationFqn: String
189+ abstract val nestedClassesShouldBeStatic: Boolean
190+ abstract val argListClassId: ClassId
186191
187192 val assertEquals by lazy { assertionId(" assertEquals" , objectClassId, objectClassId) }
188193
@@ -301,6 +306,30 @@ object TestNg : TestFramework(displayName = "TestNG") {
301306 simpleName = " DataProvider"
302307 )
303308
309+ override val nestedClassesShouldBeStatic = true
310+
311+ override val argListClassId: ClassId
312+ get() {
313+ val outerArrayId = Array <Array <Any ?>? > ::class .id
314+ val innerArrayId = BuiltinClassId (
315+ name = objectArrayClassId.name,
316+ simpleName = objectArrayClassId.simpleName,
317+ canonicalName = objectArrayClassId.canonicalName,
318+ packageName = objectArrayClassId.packageName,
319+ elementClassId = objectClassId,
320+ typeParameters = TypeParameters (listOf (objectClassId))
321+ )
322+
323+ return BuiltinClassId (
324+ name = outerArrayId.name,
325+ simpleName = outerArrayId.simpleName,
326+ canonicalName = outerArrayId.canonicalName,
327+ packageName = outerArrayId.packageName,
328+ elementClassId = innerArrayId,
329+ typeParameters = TypeParameters (listOf (innerArrayId))
330+ )
331+ }
332+
304333 @OptIn(ExperimentalStdlibApi ::class )
305334 override fun getRunTestsCommand (
306335 executionInvoke : String ,
@@ -346,14 +375,21 @@ object TestNg : TestFramework(displayName = "TestNG") {
346375}
347376
348377object Junit4 : TestFramework(" JUnit4" ) {
378+ private val parametrizedTestsNotSupportedError: Nothing
379+ get() = error(" Parametrized tests are not supported for JUnit4" )
380+
349381 override val mainPackage: String = JUNIT4_PACKAGE
350382 override val testAnnotation = " @$mainPackage .Test"
351383 override val testAnnotationFqn: String = " $mainPackage .Test"
352384
353- override val parameterizedTestAnnotation = " Parameterized tests are not supported for JUnit4"
354- override val parameterizedTestAnnotationFqn = " Parameterized tests are not supported for JUnit4"
355- override val methodSourceAnnotation = " Parameterized tests are not supported for JUnit4"
356- override val methodSourceAnnotationFqn = " Parameterized tests are not supported for JUnit4"
385+ override val parameterizedTestAnnotation
386+ get() = parametrizedTestsNotSupportedError
387+ override val parameterizedTestAnnotationFqn
388+ get() = parametrizedTestsNotSupportedError
389+ override val methodSourceAnnotation
390+ get() = parametrizedTestsNotSupportedError
391+ override val methodSourceAnnotationFqn
392+ get() = parametrizedTestsNotSupportedError
357393
358394 override val testAnnotationId = BuiltinClassId (
359395 name = " $JUNIT4_PACKAGE .Test" ,
@@ -385,6 +421,17 @@ object Junit4 : TestFramework("JUnit4") {
385421 )
386422 }
387423
424+ val enclosedClassId = BuiltinClassId (
425+ name = " org.junit.experimental.runners.Enclosed" ,
426+ canonicalName = " org.junit.experimental.runners.Enclosed" ,
427+ simpleName = " Enclosed"
428+ )
429+
430+ override val nestedClassesShouldBeStatic = true
431+
432+ override val argListClassId: ClassId
433+ get() = parametrizedTestsNotSupportedError
434+
388435 @OptIn(ExperimentalStdlibApi ::class )
389436 override fun getRunTestsCommand (
390437 executionInvoke : String ,
@@ -440,6 +487,12 @@ object Junit5 : TestFramework("JUnit5") {
440487 arguments = arrayOf(longClassId)
441488 )
442489
490+ val nestedTestClassAnnotationId = BuiltinClassId (
491+ name = " $JUNIT5_PACKAGE .Nested" ,
492+ canonicalName = " $JUNIT5_PACKAGE .Nested" ,
493+ simpleName = " Nested"
494+ )
495+
443496 override val testAnnotationId = BuiltinClassId (
444497 name = " $JUNIT5_PACKAGE .Test" ,
445498 canonicalName = " $JUNIT5_PACKAGE .Test" ,
@@ -501,6 +554,20 @@ object Junit5 : TestFramework("JUnit5") {
501554 )
502555 }
503556
557+ override val nestedClassesShouldBeStatic = false
558+
559+ override val argListClassId: ClassId
560+ get() {
561+ val arrayListId = java.util.ArrayList ::class .id
562+ return BuiltinClassId (
563+ name = arrayListId.name,
564+ simpleName = arrayListId.simpleName,
565+ canonicalName = arrayListId.canonicalName,
566+ packageName = arrayListId.packageName,
567+ typeParameters = TypeParameters (listOf (argumentsClassId))
568+ )
569+ }
570+
504571 private const val junitVersion = " 1.7.1" // TODO read it from gradle.properties
505572 private const val platformJarName: String = " junit-platform-console-standalone-$junitVersion .jar"
506573
0 commit comments