- 
                Notifications
    You must be signed in to change notification settings 
- Fork 45
Open
Labels
ctg-bugIssue is a bugIssue is a buglang-kotlinIssue is related to Kotlin language supportIssue is related to Kotlin language support
Description
Description
When user tries to use mocking for external classes UTBot creates var mockedConstruction = null which usage in the code cause type compatibility errors
To Reproduce
Steps to reproduce the behavior:
- In UTBot settings set Generated test languagetoKotlinother leave default
- Enable Force mocking static methods
- Generate tests for following code
import java.util.Random
class RandomInt {
    fun multByRandom(x: Int): Int {
        val random: Random = Random();
        return x * random.nextInt();
    }
}Expected behavior
Compilable code is generated
Actual behavior
Generated test cannot be compiled. See its beginning below.
    @Test
    fun testMultByRandom1() {
        var mockedConstruction = null
        try {
            val mockClassCounter = AtomicInteger()
            mockedConstruction = mockConstruction(Random::class.java) { RandomMock: Random,
                                                                        context: MockedConstruction.Context
             -> when (mockClassCounter.get()) {
                    0 -> {
                        (`when`(RandomMock.nextInt())).thenReturn(0)
                    }
                }
                mockClassCounter.getAndIncrement()
            }Visual proofs (screenshots, logs, images)
Metadata
Metadata
Assignees
Labels
ctg-bugIssue is a bugIssue is a buglang-kotlinIssue is related to Kotlin language supportIssue is related to Kotlin language support
Type
Projects
Status
Todo
