Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.utbot.framework.codegen.domain.MockitoStaticMocking
import org.utbot.framework.codegen.domain.NoStaticMocking
import org.utbot.framework.codegen.domain.StaticsMocking
import org.utbot.framework.codegen.domain.testFrameworkByName
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
import org.utbot.framework.plugin.api.ClassId
import org.utbot.framework.plugin.api.CodegenLanguage
import org.utbot.framework.plugin.api.ExecutableId
Expand Down Expand Up @@ -211,6 +212,7 @@ abstract class GenerateTestsAbstractCommand(name: String, help: String) :
testFramework = testFrameworkByName(testFramework),
classUnderTest = classUnderTest,
codegenLanguage = codegenLanguage,
cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(codegenLanguage),
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
generateWarningsForStaticMocking = generateWarningsForStaticMocking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import org.utbot.framework.codegen.domain.Junit5
import org.utbot.framework.codegen.domain.NoStaticMocking
import org.utbot.framework.codegen.domain.StaticsMocking
import org.utbot.framework.codegen.domain.TestFramework
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
import org.utbot.framework.concrete.UtConcreteExecutionData
import org.utbot.framework.concrete.UtConcreteExecutionResult
import org.utbot.framework.concrete.UtExecutionInstrumentation
Expand Down Expand Up @@ -85,6 +86,7 @@ object UtBotJavaApi {
testFramework = testFramework,
mockFramework = mockFramework,
codegenLanguage = codegenLanguage,
cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(codegenLanguage),
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
generateWarningsForStaticMocking = generateWarningsForStaticMocking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ open class CodeGenerator(
forceStaticMocking: ForceStaticMocking = ForceStaticMocking.defaultItem,
generateWarningsForStaticMocking: Boolean = true,
codegenLanguage: CodegenLanguage = CodegenLanguage.defaultItem,
cgLanguageAssistant: CgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(CodegenLanguage.defaultItem),
parameterizedTestSource: ParametrizedTestSource = ParametrizedTestSource.defaultItem,
runtimeExceptionTestsBehaviour: RuntimeExceptionTestsBehaviour = RuntimeExceptionTestsBehaviour.defaultItem,
hangingTestsTimeout: HangingTestsTimeout = HangingTestsTimeout(),
Expand All @@ -49,7 +50,7 @@ open class CodeGenerator(
testFramework = testFramework,
mockFramework = mockFramework,
codegenLanguage = codegenLanguage,
cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(codegenLanguage),
cgLanguageAssistant = cgLanguageAssistant,
parametrizedTestSource = parameterizedTestSource,
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.utbot.framework.plugin.sarif
import org.utbot.framework.codegen.CodeGenerator
import org.utbot.framework.codegen.domain.ForceStaticMocking
import org.utbot.framework.codegen.domain.NoStaticMocking
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
import org.utbot.framework.plugin.api.TestCaseGenerator
import org.utbot.framework.plugin.api.UtMethodTestSet
import org.utbot.framework.plugin.api.util.id
Expand Down Expand Up @@ -77,7 +78,8 @@ class GenerateTestsAndSarifReportFacade(
staticsMocking = sarifProperties.staticsMocking,
forceStaticMocking = sarifProperties.forceStaticMocking,
generateWarningsForStaticMocking = isNoStaticMocking && isForceStaticMocking,
codegenLanguage = sarifProperties.codegenLanguage
codegenLanguage = sarifProperties.codegenLanguage,
cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(sarifProperties.codegenLanguage),
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ import kotlinx.coroutines.newSingleThreadContext
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull
import kotlinx.coroutines.yield
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
import org.utbot.framework.plugin.api.util.isSynthetic

internal const val junitVersion = 4
Expand Down Expand Up @@ -223,7 +224,8 @@ fun runGeneration(
testFramework = junitByVersion(junitVersion),
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
generateWarningsForStaticMocking = false
generateWarningsForStaticMocking = false,
cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(CodegenLanguage.defaultItem),
)

logger.info().bracket("class ${cut.fqn}", { statsForClass }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.utbot.framework.codegen.domain.ParametrizedTestSource
import org.utbot.framework.codegen.domain.RuntimeExceptionTestsBehaviour
import org.utbot.framework.codegen.domain.StaticsMocking
import org.utbot.framework.codegen.domain.TestFramework
import org.utbot.framework.codegen.domain.context.CgContext
import org.utbot.framework.codegen.domain.models.CgLiteral
import org.utbot.framework.codegen.domain.models.CgMethodTestSet
import org.utbot.framework.codegen.domain.models.CgVariable
Expand Down Expand Up @@ -61,24 +60,9 @@ class PythonCodeGenerator(
runtimeExceptionTestsBehaviour=runtimeExceptionTestsBehaviour,
hangingTestsTimeout=hangingTestsTimeout,
enableTestsTimeout=enableTestsTimeout,
testClassPackageName=testClassPackageName
testClassPackageName=testClassPackageName,
cgLanguageAssistant = PythonCgLanguageAssistant,
) {
override var context: CgContext = CgContext(
classUnderTest = classUnderTest,
paramNames = paramNames,
testFramework = testFramework,
mockFramework = mockFramework,
cgLanguageAssistant = PythonCgLanguageAssistant,
parametrizedTestSource = parameterizedTestSource,
staticsMocking = staticsMocking,
forceStaticMocking = forceStaticMocking,
generateWarningsForStaticMocking = generateWarningsForStaticMocking,
runtimeExceptionTestsBehaviour = runtimeExceptionTestsBehaviour,
hangingTestsTimeout = hangingTestsTimeout,
enableTestsTimeout = enableTestsTimeout,
testClassPackageName = testClassPackageName
)

fun pythonGenerateAsStringWithTestReport(
cgTestSets: List<CgMethodTestSet>,
importModules: Set<PythonImport>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.utbot.framework.codegen.domain.ForceStaticMocking
import org.utbot.framework.codegen.domain.ParametrizedTestSource
import org.utbot.framework.codegen.domain.StaticsMocking
import org.utbot.framework.codegen.domain.TestFramework
import org.utbot.framework.codegen.services.language.CgLanguageAssistant
import org.utbot.framework.codegen.tree.ututils.UtilClassKind
import org.utbot.framework.codegen.tree.ututils.UtilClassKind.Companion.UT_UTILS_INSTANCE_NAME
import org.utbot.framework.plugin.api.CodegenLanguage
Expand Down Expand Up @@ -271,6 +272,7 @@ class TestCodeGeneratorPipeline(private val testFrameworkConfiguration: TestFram
forceStaticMocking = forceStaticMocking,
generateWarningsForStaticMocking = false,
codegenLanguage = codegenLanguage,
cgLanguageAssistant = CgLanguageAssistant.getByCodegenLanguage(codegenLanguage),
parameterizedTestSource = parametrizedTestSource,
runtimeExceptionTestsBehaviour = runtimeExceptionTestsBehaviour,
enableTestsTimeout = enableTestsTimeout
Expand Down