-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Assignees
@tyuldashev
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 language
toKotlin
other 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
Type
Projects
Status
Todo