Simple tool for generating unit-test for Kotlin code. Based on UTGen library.
- Supported language: Kotlin.
- Generate stub unit-tests.
- Find your code.
- Right click on kotlin file.
- Choose "Generate Unit-Tests".
- You can find test in test folder.
Your source class is:
package com.example.demo1
class MyTestClass(
private val a: String,
private val b: String,
) {
fun testMethod(): MyRetObj {
return MyRetObj(true)
}
}
data class MyRetObj(
val a: Boolean
)
Library generates code:
package com.example.demo1
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
internal class MyTestClassTest {
private val obj: MyTestClass = MyTestClass()
@Test
public fun testMethod_goldencase() {
TODO("Implement")
val expected = MyRetObj()
val actual = obj.testMethod()
Assertions.assertEquals(expected, actual)
}
}