Skip to content

Commit a208ceb

Browse files
authored
Enable disabled test due to the fix #1266 (#1277)
Enable the disabled test for parameterization
1 parent 721fa0e commit a208ceb

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/collections/CustomerExamplesTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal class CustomerExamplesTest: UtValueTestCaseChecker(
1616
testClass = CustomerExamples::class,
1717
testCodeGeneration = true,
1818
pipelines = listOf(
19-
TestLastStage(CodegenLanguage.JAVA, lastStage = TestExecution, parameterizedModeLastStage = Compilation),
19+
TestLastStage(CodegenLanguage.JAVA, lastStage = TestExecution),
2020
TestLastStage(CodegenLanguage.KOTLIN, lastStage = CodeGeneration)
2121
)
2222
) {

utbot-framework-test/src/test/kotlin/org/utbot/examples/mixed/PrivateConstructorExampleTest.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,11 @@ import org.utbot.framework.plugin.api.CodegenLanguage
77
import org.utbot.testcheckers.eq
88
import org.utbot.tests.infrastructure.Compilation
99

10-
// TODO parameterized tests disabled due to https://github.com/UnitTestBot/UTBotJava/issues/1266
1110
internal class PrivateConstructorExampleTest : UtValueTestCaseChecker(
1211
testClass = PrivateConstructorExample::class,
1312
pipelines = listOf(
14-
TestLastStage(
15-
CodegenLanguage.JAVA,
16-
parameterizedModeLastStage = Compilation
17-
),
18-
TestLastStage(
19-
CodegenLanguage.KOTLIN,
20-
parameterizedModeLastStage = Compilation
21-
)
13+
TestLastStage(CodegenLanguage.JAVA),
14+
TestLastStage(CodegenLanguage.KOTLIN)
2215
)
2316
) {
2417

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,9 +1487,8 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
14871487
substituteStaticFields(statics, isParametrized = true)
14881488

14891489
// build this instance
1490-
thisInstance =
1491-
genericExecution.stateBefore.thisInstance?.let {
1492-
variableConstructor.getOrCreateVariable(it)
1490+
thisInstance = genericExecution.stateBefore.thisInstance?.let {
1491+
currentMethodParameters[CgParameterKind.ThisInstance]
14931492
}
14941493

14951494
// build arguments for method under test and parameterized test
@@ -1552,6 +1551,20 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
15521551
val executableUnderTestParameters = testSet.executableId.executable.parameters
15531552

15541553
return mutableListOf<CgParameterDeclaration>().apply {
1554+
// this instance
1555+
genericExecution.stateBefore.thisInstance?.let {
1556+
val type = wrapTypeIfRequired(it.classId)
1557+
val thisInstance = CgParameterDeclaration(
1558+
parameter = declareParameter(
1559+
type = type,
1560+
name = nameGenerator.variableName(type)
1561+
),
1562+
isReferenceType = true
1563+
)
1564+
this += thisInstance
1565+
currentMethodParameters[CgParameterKind.ThisInstance] = thisInstance.parameter
1566+
}
1567+
15551568
// arguments
15561569
for (index in genericExecution.stateBefore.parameters.indices) {
15571570
val argumentName = paramNames[executableUnderTest]?.get(index)
@@ -1663,6 +1676,10 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
16631676
private fun createExecutionArguments(testSet: CgMethodTestSet, execution: UtExecution): List<CgExpression> {
16641677
val arguments = mutableListOf<CgExpression>()
16651678

1679+
execution.stateBefore.thisInstance?.let {
1680+
arguments += variableConstructor.getOrCreateVariable(it)
1681+
}
1682+
16661683
for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
16671684
val argumentName = paramNames[testSet.executableId]?.get(paramIndex)
16681685
arguments += variableConstructor.getOrCreateVariable(paramModel, argumentName)
@@ -1673,7 +1690,6 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
16731690
arguments += variableConstructor.getOrCreateVariable(model, field.name)
16741691
}
16751692

1676-
16771693
val method = currentExecutable!!
16781694
val needsReturnValue = method.returnType != voidClassId
16791695
val containsFailureExecution = containsFailureExecution(testSet)

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/tree/CgElement.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,7 @@ data class CgParameterDeclaration(
728728
* - exception expected from MUT with the given arguments
729729
*/
730730
sealed class CgParameterKind {
731+
object ThisInstance : CgParameterKind()
731732
data class Argument(val index: Int) : CgParameterKind()
732733
data class Statics(val model: UtModel) : CgParameterKind()
733734
object ExpectedResult : CgParameterKind()

0 commit comments

Comments
 (0)