diff --git a/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt b/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt index db5831a382..8bf70f17bf 100644 --- a/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt +++ b/utbot-cli/src/main/kotlin/org/utbot/cli/GenerateTestsAbstractCommand.kt @@ -20,6 +20,7 @@ import org.utbot.framework.codegen.CodeGenerator import org.utbot.framework.codegen.domain.ForceStaticMocking import org.utbot.framework.codegen.domain.MockitoStaticMocking import org.utbot.framework.codegen.domain.NoStaticMocking +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.testFrameworkByName import org.utbot.framework.codegen.services.language.CgLanguageAssistant @@ -211,6 +212,8 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) : return CodeGenerator( testFramework = testFrameworkByName(testFramework), classUnderTest = classUnderTest, + //TODO: Support Spring projects in utbot-cli if requested + projectType = ProjectType.PureJvm, codegenLanguage = codegenLanguage, cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(codegenLanguage), staticsMocking = staticsMocking, diff --git a/utbot-framework-test/src/test/java/org/utbot/examples/manual/UtBotJavaApiTest.java b/utbot-framework-test/src/test/java/org/utbot/examples/manual/UtBotJavaApiTest.java index 73cde6f544..71498407e1 100644 --- a/utbot-framework-test/src/test/java/org/utbot/examples/manual/UtBotJavaApiTest.java +++ b/utbot-framework-test/src/test/java/org/utbot/examples/manual/UtBotJavaApiTest.java @@ -23,6 +23,7 @@ import org.utbot.framework.codegen.domain.ForceStaticMocking; import org.utbot.framework.codegen.domain.Junit4; import org.utbot.framework.codegen.domain.MockitoStaticMocking; +import org.utbot.framework.codegen.domain.ProjectType; import org.utbot.framework.plugin.api.*; import org.utbot.framework.plugin.api.util.UtContext; import org.utbot.framework.plugin.services.JdkInfoDefaultProvider; @@ -148,6 +149,7 @@ public void testMultiMethodClass() { classpath, dependencyClassPath, MultiMethodExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -222,6 +224,7 @@ public void testCustomPackage() { classpath, dependencyClassPath, ClassRefExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -245,6 +248,7 @@ public void testCustomPackage() { classpath, dependencyClassPath, ClassRefExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -321,6 +325,7 @@ public void testOnObjectWithAssignedArrayField() { classpath, dependencyClassPath, AssignedArrayExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -343,6 +348,7 @@ public void testOnObjectWithAssignedArrayField() { classpath, dependencyClassPath, AssignedArrayExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -405,6 +411,7 @@ public void testClassRef() { classpath, dependencyClassPath, ClassRefExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -428,6 +435,7 @@ public void testClassRef() { classpath, dependencyClassPath, ClassRefExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -510,6 +518,7 @@ public void testObjectWithPublicFields() { classpath, dependencyClassPath, DirectAccessExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -532,6 +541,7 @@ public void testObjectWithPublicFields() { classpath, dependencyClassPath, DirectAccessExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -613,6 +623,7 @@ public void testObjectWithPublicFieldsWithAssembleModel() { classpath, dependencyClassPath, DirectAccessExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -702,6 +713,7 @@ public void testOnObjectWithArrayOfPrimitiveArrays() { classpath, dependencyClassPath, ArrayOfPrimitiveArraysExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -724,6 +736,7 @@ public void testOnObjectWithArrayOfPrimitiveArrays() { classpath, dependencyClassPath, ArrayOfPrimitiveArraysExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -798,6 +811,7 @@ public void testProvided3() { classpath, dependencyClassPath, Demo9.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -870,6 +884,7 @@ public void testCustomAssertion() { classpath, dependencyClassPath, Trivial.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -893,6 +908,7 @@ public void testCustomAssertion() { classpath, dependencyClassPath, Trivial.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -982,6 +998,7 @@ public void testProvided3Reused() { classpath, dependencyClassPath, compiledClass, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -1055,6 +1072,7 @@ public void testProvided3Reused() { classpath, dependencyClassPath, recompiledClass, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -1120,6 +1138,7 @@ public void testProvided1() { classpath, dependencyClassPath, ProvidedExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, @@ -1196,6 +1215,7 @@ public void testOnObjectWithArrayOfComplexArrays() { classpath, dependencyClassPath, ArrayOfComplexArraysExample.class, + ProjectType.PureJvm, Junit4.INSTANCE, MOCKITO, CodegenLanguage.JAVA, diff --git a/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt b/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt index ec8a869fc1..23f7195a20 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/external/api/UtBotJavaApi.kt @@ -7,6 +7,7 @@ import org.utbot.framework.codegen.CodeGenerator import org.utbot.framework.codegen.domain.ForceStaticMocking import org.utbot.framework.codegen.domain.Junit5 import org.utbot.framework.codegen.domain.NoStaticMocking +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.codegen.services.language.CgLanguageAssistant @@ -55,6 +56,7 @@ object UtBotJavaApi { classpath: String, dependencyClassPath: String, classUnderTest: Class<*>, + projectType: ProjectType = ProjectType.PureJvm, testFramework: TestFramework = Junit5, mockFramework: MockFramework = MockFramework.MOCKITO, codegenLanguage: CodegenLanguage = CodegenLanguage.JAVA, @@ -82,6 +84,7 @@ object UtBotJavaApi { return withUtContext(utContext) { val codeGenerator = CodeGenerator( classUnderTest = classUnderTest.id, + projectType = projectType, testFramework = testFramework, mockFramework = mockFramework, codegenLanguage = codegenLanguage, diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGenerator.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGenerator.kt index 1ecf3d8818..ec5b7c16e3 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGenerator.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/codegen/CodeGenerator.kt @@ -30,8 +30,7 @@ import java.time.format.DateTimeFormatter open class CodeGenerator( val classUnderTest: ClassId, - //TODO: support setting `projectType` in Sarif plugins, UtBotJava api, etc. - val projectType: ProjectType = PureJvm, + val projectType: ProjectType, paramNames: MutableMap> = mutableMapOf(), generateUtilClassFile: Boolean = false, testFramework: TestFramework = TestFramework.defaultItem, @@ -82,10 +81,8 @@ open class CodeGenerator( return withCustomContext(testClassCustomName) { context.withTestClassFileScope { when (context.projectType) { - PureJvm, - Python, - JavaScript -> generateForSimpleClass(cgTestSets) Spring -> generateForSpringClass(cgTestSets) + else -> generateForSimpleClass(cgTestSets) } } } diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt index f870126799..46d3b94036 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/GenerateTestsAndSarifReportFacade.kt @@ -71,6 +71,7 @@ class GenerateTestsAndSarifReportFacade( return CodeGenerator( classUnderTest = targetClass.classUnderTest.id, + projectType = sarifProperties.projectType, testFramework = sarifProperties.testFramework, mockFramework = sarifProperties.mockFramework, staticsMocking = sarifProperties.staticsMocking, diff --git a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/SarifExtensionProvider.kt b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/SarifExtensionProvider.kt index 9840809dd0..f71370b066 100644 --- a/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/SarifExtensionProvider.kt +++ b/utbot-framework/src/main/kotlin/org/utbot/framework/plugin/sarif/SarifExtensionProvider.kt @@ -6,6 +6,8 @@ import org.utbot.framework.codegen.domain.Junit4 import org.utbot.framework.codegen.domain.Junit5 import org.utbot.framework.codegen.domain.MockitoStaticMocking import org.utbot.framework.codegen.domain.NoStaticMocking +import org.utbot.framework.codegen.domain.ProjectType +import org.utbot.framework.codegen.domain.ProjectType.* import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.codegen.domain.TestNg @@ -51,6 +53,8 @@ interface SarifExtensionProvider { */ val testPrivateMethods: Boolean + val projectType: ProjectType + val testFramework: TestFramework val mockFramework: MockFramework @@ -76,6 +80,15 @@ interface SarifExtensionProvider { // transform functions + fun projectTypeParse(projectType: String): ProjectType = + when (projectType.toLowerCase()) { + "purejvm" -> PureJvm + "spring" -> Spring + "python" -> Python + "javascript" -> JavaScript + else -> error("Parameter projectType == '$projectType', but it can take only 'pureJvm', 'spring', 'python' or 'javascript'") + } + fun testFrameworkParse(testFramework: String): TestFramework = when (testFramework.toLowerCase()) { "junit4" -> Junit4 diff --git a/utbot-gradle/docs/utbot-gradle.md b/utbot-gradle/docs/utbot-gradle.md index 745cc48468..4891d32c72 100644 --- a/utbot-gradle/docs/utbot-gradle.md +++ b/utbot-gradle/docs/utbot-gradle.md @@ -41,6 +41,7 @@ __Groovy:__ sarifReportsRelativeRoot = 'build/generated/sarif' markGeneratedTestsDirectoryAsTestSourcesRoot = true testPrivateMethods = false + projectType = 'purejvm' testFramework = 'junit5' mockFramework = 'mockito' generationTimeout = 60000L @@ -60,6 +61,7 @@ __Kotlin DSL:__ sarifReportsRelativeRoot.set("build/generated/sarif") markGeneratedTestsDirectoryAsTestSourcesRoot.set(true) testPrivateMethods.set(false) + projectType.set("purejvm") testFramework.set("junit5") mockFramework.set("mockito") generationTimeout.set(60000L) @@ -81,6 +83,7 @@ generateTestsAndSarifReport -PgeneratedTestsRelativeRoot='build/generated/test' -PsarifReportsRelativeRoot='build/generated/sarif' -PtestPrivateMethods='false' + -PtestProjectType=purejvm -PtestFramework=junit5 -PmockFramework=mockito -PgenerationTimeout=60000 @@ -119,6 +122,14 @@ generateTestsAndSarifReport - Generate tests for private methods or not. - By default, `false` is used. +- `projectType` – + - The type of project being analyzed. + - Can be one of: + - `'purejvm'` _(by default)_ + - `'spring'` + - `'python'` + - `'javascript'` + - `testFramework` – - The name of the test framework to be used. - Can be one of: diff --git a/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtension.kt b/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtension.kt index 7737836899..5fda696742 100644 --- a/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtension.kt +++ b/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtension.kt @@ -49,6 +49,12 @@ abstract class SarifGradleExtension { @get:Input abstract val testPrivateMethods: Property + /** + * Can be one of: 'purejvm', 'spring', 'python', 'javascript`. + */ + @get:Input + abstract val projectType: Property + /** * Can be one of: 'junit4', 'junit5', 'testng'. */ diff --git a/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProvider.kt b/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProvider.kt index c747d55aa3..de56527fb6 100644 --- a/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProvider.kt +++ b/utbot-gradle/src/main/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProvider.kt @@ -3,6 +3,7 @@ package org.utbot.gradle.plugin.extension import org.gradle.api.Project import org.utbot.common.PathUtil.toPath import org.utbot.framework.codegen.domain.ForceStaticMocking +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.plugin.api.ClassId @@ -57,6 +58,11 @@ class SarifGradleExtensionProvider( ?: extension.testPrivateMethods.orNull ?: false + override val projectType: ProjectType + get() = (taskParameters["projectType"] ?: extension.projectType.orNull) + ?.let(::projectTypeParse) + ?: ProjectType.PureJvm + override val testFramework: TestFramework get() = (taskParameters["testFramework"] ?: extension.testFramework.orNull) ?.let(::testFrameworkParse) diff --git a/utbot-gradle/src/test/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProviderTest.kt b/utbot-gradle/src/test/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProviderTest.kt index e153ea21f8..9432b519fe 100644 --- a/utbot-gradle/src/test/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProviderTest.kt +++ b/utbot-gradle/src/test/kotlin/org/utbot/gradle/plugin/extension/SarifGradleExtensionProviderTest.kt @@ -13,6 +13,8 @@ import org.utbot.framework.codegen.domain.Junit4 import org.utbot.framework.codegen.domain.Junit5 import org.utbot.framework.codegen.domain.MockitoStaticMocking import org.utbot.framework.codegen.domain.NoStaticMocking +import org.utbot.framework.codegen.domain.ProjectType +import org.utbot.framework.codegen.domain.ProjectType.* import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.codegen.domain.TestNg @@ -255,6 +257,69 @@ class SarifGradleExtensionProviderTest { } } + @Nested + @DisplayName("projectType") + inner class ProjectTypeTest { + @Test + fun `should be ProjectType defaultItem by default`() { + setProjectTypeInExtension(null) + assertEquals(PureJvm, extensionProvider.projectType) + } + + @Test + fun `should be equal to PureJvm`() { + setProjectTypeInExtension("purejvm") + assertEquals(PureJvm, extensionProvider.projectType) + } + + @Test + fun `should be equal to Spring`() { + setProjectTypeInExtension("spring") + assertEquals(Spring, extensionProvider.projectType) + } + + @Test + fun `should be equal to Python`() { + setProjectTypeInExtension("python") + assertEquals(Python, extensionProvider.projectType) + } + + @Test + fun `should be equal to JavaScript`() { + setProjectTypeInExtension("javascript") + assertEquals(JavaScript, extensionProvider.projectType) + } + + @Test + fun `should fail on unknown project type`() { + setProjectTypeInExtension("unknown") + assertThrows { + extensionProvider.projectType + } + } + + @Test + fun `should be provided from the task parameters`() { + setProjectTypeInTaskParameters("spring") + assertEquals(Spring, extensionProvider.projectType) + } + + @Test + fun `should be provided from the task parameters, not from the extension`() { + setProjectTypeInTaskParameters("python") + setProjectTypeInExtension("javascript") + assertEquals(Python, extensionProvider.projectType) + } + + private fun setProjectTypeInExtension(value: String?) { + Mockito.`when`(extensionMock.projectType).thenReturn(createStringProperty(value)) + } + + private fun setProjectTypeInTaskParameters(value: String) { + extensionProvider.taskParameters = mapOf("projectType" to value) + } + } + @Nested @DisplayName("testFramework") inner class TestFrameworkTest { diff --git a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt index 6840bc3a11..8978bdb61f 100644 --- a/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt +++ b/utbot-intellij/src/main/kotlin/org/utbot/intellij/plugin/generator/UtTestsDialogProcessor.kt @@ -178,9 +178,6 @@ object UtTestsDialogProcessor { val staticMockingConfigured = model.staticsMocking.isConfigured val applicationContext = when (model.projectType) { - PureJvm, - Python, - JavaScript -> ApplicationContext(mockFrameworkInstalled, staticMockingConfigured) Spring -> { val shouldUseImplementors = when (model.typeReplacementApproach) { TypeReplacementApproach.DO_NOT_REPLACE -> false @@ -195,6 +192,7 @@ object UtTestsDialogProcessor { shouldUseImplementors = shouldUseImplementors, ) } + else -> ApplicationContext(mockFrameworkInstalled, staticMockingConfigured) } val process = EngineProcess.createBlocking(project, classNameToPath) diff --git a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt index d3f7b6a8cd..cae9c46d62 100644 --- a/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt +++ b/utbot-junit-contest/src/main/kotlin/org/utbot/contest/Contest.kt @@ -52,6 +52,7 @@ import kotlinx.coroutines.newSingleThreadContext import kotlinx.coroutines.runBlocking import kotlinx.coroutines.withTimeoutOrNull import org.utbot.framework.SummariesGenerationType +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.services.language.CgLanguageAssistant import org.utbot.framework.minimization.minimizeExecutions import org.utbot.framework.plugin.api.* @@ -221,6 +222,7 @@ fun runGeneration( val codeGenerator = CodeGenerator( cut.classId, + projectType = ProjectType.PureJvm, testFramework = junitByVersion(junitVersion), staticsMocking = staticsMocking, forceStaticMocking = forceStaticMocking, diff --git a/utbot-maven/docs/utbot-maven.md b/utbot-maven/docs/utbot-maven.md index 93c893a375..c56a521ab3 100644 --- a/utbot-maven/docs/utbot-maven.md +++ b/utbot-maven/docs/utbot-maven.md @@ -41,6 +41,7 @@ For example, the following configuration may be used: target/generated/sarif true false + purejvm junit5 mockito 60000L @@ -84,6 +85,14 @@ For example, the following configuration may be used: - Generate tests for private methods or not. - By default, `false` is used. +- `projectType` – + - The type of project being analyzed. + - Can be one of: + - `'purejvm'` _(by default)_ + - `'spring'` + - `'python'` + - `'javascript'` + - `testFramework` – - The name of the test framework to be used. - Can be one of: diff --git a/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/GenerateTestsAndSarifReportMojo.kt b/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/GenerateTestsAndSarifReportMojo.kt index 1a016c98cb..17ca268d3a 100644 --- a/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/GenerateTestsAndSarifReportMojo.kt +++ b/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/GenerateTestsAndSarifReportMojo.kt @@ -80,6 +80,12 @@ class GenerateTestsAndSarifReportMojo : AbstractMojo() { @Parameter(defaultValue = "false") internal var testPrivateMethods: Boolean = false + /** + * Can be one of: 'purejvm', 'spring', 'python', 'javascript'. + */ + @Parameter(defaultValue = "purejvm") + internal lateinit var projectType: String + /** * Can be one of: 'junit4', 'junit5', 'testng'. */ diff --git a/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProvider.kt b/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProvider.kt index 77e1e6bdc1..689ecb23af 100644 --- a/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProvider.kt +++ b/utbot-maven/src/main/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProvider.kt @@ -1,6 +1,7 @@ package org.utbot.maven.plugin.extension import org.utbot.framework.codegen.domain.ForceStaticMocking +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.plugin.api.ClassId @@ -36,6 +37,9 @@ class SarifMavenConfigurationProvider( override val testPrivateMethods: Boolean get() = generateTestsAndSarifReportMojo.testPrivateMethods + override val projectType: ProjectType + get() = projectTypeParse(generateTestsAndSarifReportMojo.projectType) + override val testFramework: TestFramework get() = testFrameworkParse(generateTestsAndSarifReportMojo.testFramework) diff --git a/utbot-maven/src/test/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProviderTest.kt b/utbot-maven/src/test/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProviderTest.kt index 671c5dd7d6..3e965e0371 100644 --- a/utbot-maven/src/test/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProviderTest.kt +++ b/utbot-maven/src/test/kotlin/org/utbot/maven/plugin/extension/SarifMavenConfigurationProviderTest.kt @@ -8,6 +8,7 @@ import org.utbot.engine.Mocker import org.utbot.framework.codegen.domain.ForceStaticMocking import org.utbot.framework.codegen.domain.Junit5 import org.utbot.framework.codegen.domain.MockitoStaticMocking +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.plugin.api.ClassId import org.utbot.framework.plugin.api.CodegenLanguage import org.utbot.framework.plugin.api.MockFramework @@ -59,6 +60,11 @@ class SarifMavenConfigurationProviderTest : AbstractMojoTestCase() { Assertions.assertEquals(true, configurationProvider.testPrivateMethods) } + @Test + fun `projectType should be provided from the configuration`() { + Assertions.assertEquals(ProjectType.PureJvm, configurationProvider.projectType) + } + @Test fun `testFramework should be provided from the configuration`() { Assertions.assertEquals(Junit5, configurationProvider.testFramework) diff --git a/utbot-testing/src/main/kotlin/org/utbot/testing/TestCodeGeneratorPipeline.kt b/utbot-testing/src/main/kotlin/org/utbot/testing/TestCodeGeneratorPipeline.kt index 571dce5112..a62a80e4cf 100644 --- a/utbot-testing/src/main/kotlin/org/utbot/testing/TestCodeGeneratorPipeline.kt +++ b/utbot-testing/src/main/kotlin/org/utbot/testing/TestCodeGeneratorPipeline.kt @@ -9,6 +9,7 @@ import org.utbot.framework.codegen.CodeGenerator import org.utbot.framework.codegen.CodeGeneratorResult import org.utbot.framework.codegen.domain.ForceStaticMocking import org.utbot.framework.codegen.domain.ParametrizedTestSource +import org.utbot.framework.codegen.domain.ProjectType import org.utbot.framework.codegen.domain.StaticsMocking import org.utbot.framework.codegen.domain.TestFramework import org.utbot.framework.codegen.services.language.CgLanguageAssistant @@ -265,6 +266,7 @@ class TestCodeGeneratorPipeline(private val testFrameworkConfiguration: TestFram val codeGenerator = with(testFrameworkConfiguration) { CodeGenerator( classUnderTest.id, + projectType = ProjectType.PureJvm, generateUtilClassFile = generateUtilClassFile, paramNames = params, testFramework = testFramework,