Skip to content

UTBot generates uncompilable Kotlin parametrized tests #1104

Description

@tyuldashev

Description

When user tries to generate parametrized test for Kotlin code as result she gets uncompilable code

To Reproduce

Steps to reproduce the behavior:

  1. Invoke test generation for the code below, with enabled setting Parametrized tests
classA {
funf(a:Int, b:Int): Int {
return a + b;
}
}

Expected behavior

Executable tests are generated

Actual behavior

Tests cannot be compiled and executed.

Visual proofs (screenshots, logs, images)
Resulted code and errors:

image

classATest {
///region Test suites for executable org.test.A.f///region Parameterized test for method f(int, int)
@ParameterizedTest
@MethodSource("org.test.ATest#provideDataForF")
funparameterizedTestsForF(a:A?,
a1:Int,
b:Int,
expectedResult:Int?
) {
val actual = a.f(a1, b) // #1 error
assertEquals(expectedResult, actual)
}
///endregion///endregioncompanionobject {
///region Data providers
@JvmStatic
funprovideDataForF(): java.util.ArrayList // #2 error
{
val argList = java.util.ArrayList() // #3 errorrun {
val a =A()
val testCaseObjects = kotlin.Array<Any?>(4) { null }
testCaseObjects[0] = a
testCaseObjects[1] =-1
testCaseObjects[2] =1
testCaseObjects[3] =0
argList.add(arguments(testCaseObjects))
}
return argList
}
///endregion
}
}

Metadata

Metadata

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a buglang-kotlinIssue is related to Kotlin language support

Type

No type

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions