Skip to content

divinenickname/utgen-kotlin-idea-plugin

Repository files navigation

GitHub license

Logo image. Red circle with letter U inside.

UTGen Kotlin IDEA IDE plugin

Simple tool for generating unit-test for Kotlin code. Based on UTGen library.

Features

  • Supported language: Kotlin.
  • Generate stub unit-tests.

How to use

  1. Find your code.
  2. Right click on kotlin file.
  3. Choose "Generate Unit-Tests".
  4. You can find test in test folder.

Screenshot 1 Screenshot 2 Screenshot 3

Example

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)
    }
}