@@ -3,12 +3,14 @@ package org.utbot.framework.codegen
3
3
import org.utbot.framework.DEFAULT_CONCRETE_EXECUTION_TIMEOUT_IN_CHILD_PROCESS_MS
4
4
import org.utbot.framework.codegen.model.constructor.builtin.mockitoClassId
5
5
import org.utbot.framework.codegen.model.constructor.builtin.ongoingStubbingClassId
6
+ import org.utbot.framework.codegen.model.constructor.util.argumentsClassId
6
7
import org.utbot.framework.codegen.model.tree.CgClassId
7
8
import org.utbot.framework.plugin.api.BuiltinClassId
8
9
import org.utbot.framework.plugin.api.ClassId
9
10
import org.utbot.framework.plugin.api.CodeGenerationSettingBox
10
11
import org.utbot.framework.plugin.api.CodeGenerationSettingItem
11
12
import org.utbot.framework.plugin.api.MethodId
13
+ import org.utbot.framework.plugin.api.TypeParameters
12
14
import org.utbot.framework.plugin.api.isolateCommandLineArgumentsToArgumentFile
13
15
import org.utbot.framework.plugin.api.util.booleanArrayClassId
14
16
import org.utbot.framework.plugin.api.util.booleanClassId
@@ -28,6 +30,7 @@ import org.utbot.framework.plugin.api.util.shortArrayClassId
28
30
import org.utbot.framework.plugin.api.util.voidClassId
29
31
import java.io.File
30
32
import org.utbot.framework.plugin.api.util.longClassId
33
+ import org.utbot.framework.plugin.api.util.objectArrayClassId
31
34
import org.utbot.framework.plugin.api.util.voidWrapperClassId
32
35
33
36
data class TestClassFile (val packageName : String , val imports : List <Import >, val testClass : String )
@@ -183,6 +186,8 @@ sealed class TestFramework(
183
186
abstract val methodSourceAnnotation: String
184
187
abstract val methodSourceAnnotationId: ClassId
185
188
abstract val methodSourceAnnotationFqn: String
189
+ abstract val nestedClassesShouldBeStatic: Boolean
190
+ abstract val argListClassId: ClassId
186
191
187
192
val assertEquals by lazy { assertionId(" assertEquals" , objectClassId, objectClassId) }
188
193
@@ -301,6 +306,30 @@ object TestNg : TestFramework(displayName = "TestNG") {
301
306
simpleName = " DataProvider"
302
307
)
303
308
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
+
304
333
@OptIn(ExperimentalStdlibApi ::class )
305
334
override fun getRunTestsCommand (
306
335
executionInvoke : String ,
@@ -346,14 +375,21 @@ object TestNg : TestFramework(displayName = "TestNG") {
346
375
}
347
376
348
377
object Junit4 : TestFramework(" JUnit4" ) {
378
+ private val parametrizedTestsNotSupportedError: Nothing
379
+ get() = error(" Parametrized tests are not supported for JUnit4" )
380
+
349
381
override val mainPackage: String = JUNIT4_PACKAGE
350
382
override val testAnnotation = " @$mainPackage .Test"
351
383
override val testAnnotationFqn: String = " $mainPackage .Test"
352
384
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
357
393
358
394
override val testAnnotationId = BuiltinClassId (
359
395
name = " $JUNIT4_PACKAGE .Test" ,
@@ -385,6 +421,17 @@ object Junit4 : TestFramework("JUnit4") {
385
421
)
386
422
}
387
423
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
+
388
435
@OptIn(ExperimentalStdlibApi ::class )
389
436
override fun getRunTestsCommand (
390
437
executionInvoke : String ,
@@ -440,6 +487,12 @@ object Junit5 : TestFramework("JUnit5") {
440
487
arguments = arrayOf(longClassId)
441
488
)
442
489
490
+ val nestedTestClassAnnotationId = BuiltinClassId (
491
+ name = " $JUNIT5_PACKAGE .Nested" ,
492
+ canonicalName = " $JUNIT5_PACKAGE .Nested" ,
493
+ simpleName = " Nested"
494
+ )
495
+
443
496
override val testAnnotationId = BuiltinClassId (
444
497
name = " $JUNIT5_PACKAGE .Test" ,
445
498
canonicalName = " $JUNIT5_PACKAGE .Test" ,
@@ -501,6 +554,20 @@ object Junit5 : TestFramework("JUnit5") {
501
554
)
502
555
}
503
556
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
+
504
571
private const val junitVersion = " 1.7.1" // TODO read it from gradle.properties
505
572
private const val platformJarName: String = " junit-platform-console-standalone-$junitVersion .jar"
506
573
0 commit comments