@@ -1487,9 +1487,8 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
1487
1487
substituteStaticFields(statics, isParametrized = true )
1488
1488
1489
1489
// build this instance
1490
- thisInstance =
1491
- genericExecution.stateBefore.thisInstance?.let {
1492
- variableConstructor.getOrCreateVariable(it)
1490
+ thisInstance = genericExecution.stateBefore.thisInstance?.let {
1491
+ currentMethodParameters[CgParameterKind .ThisInstance ]
1493
1492
}
1494
1493
1495
1494
// build arguments for method under test and parameterized test
@@ -1552,6 +1551,20 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
1552
1551
val executableUnderTestParameters = testSet.executableId.executable.parameters
1553
1552
1554
1553
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
+
1555
1568
// arguments
1556
1569
for (index in genericExecution.stateBefore.parameters.indices) {
1557
1570
val argumentName = paramNames[executableUnderTest]?.get(index)
@@ -1663,6 +1676,10 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
1663
1676
private fun createExecutionArguments (testSet : CgMethodTestSet , execution : UtExecution ): List <CgExpression > {
1664
1677
val arguments = mutableListOf<CgExpression >()
1665
1678
1679
+ execution.stateBefore.thisInstance?.let {
1680
+ arguments + = variableConstructor.getOrCreateVariable(it)
1681
+ }
1682
+
1666
1683
for ((paramIndex, paramModel) in execution.stateBefore.parameters.withIndex()) {
1667
1684
val argumentName = paramNames[testSet.executableId]?.get(paramIndex)
1668
1685
arguments + = variableConstructor.getOrCreateVariable(paramModel, argumentName)
@@ -1673,7 +1690,6 @@ open class CgMethodConstructor(val context: CgContext) : CgContextOwner by conte
1673
1690
arguments + = variableConstructor.getOrCreateVariable(model, field.name)
1674
1691
}
1675
1692
1676
-
1677
1693
val method = currentExecutable!!
1678
1694
val needsReturnValue = method.returnType != voidClassId
1679
1695
val containsFailureExecution = containsFailureExecution(testSet)
0 commit comments