Skip to content

Getting Started

Clikt Testkit provides a testing dsl for the Clikt command line parser library:

class HelloWorld : CliktCommand() {
    override fun run() {
        echo("Hello World!")
    }
}

HelloWorld().test {
    expectOutput("Hello World!")
}

Compared to testing with vanilla Clikt, you benefit from

  • Easier setup. Just call .test{} on the command you want to test and start writing assertions. No .parse(), catching ProgramResult or overwriting the context to set environment variables.
  • Functions to assert on console output and provide console input in your test.

Use Clikt Testkit in your project

Maven Central

Clikt Testkit is published through Maven Central. To use it in your Gradle project, include the following dependency:

dependencies {
    implementation("com.wolpl.clikt-testkit:clikt-testkit:1.0.0")
}

You can also select a specific target platform, by appending it to the library name, e.g. for the JVM:

dependencies {
    implementation("com.wolpl.clikt-testkit:clikt-testkit-jvm:1.0.0")
}

Snapshots

Sonatype Nexus (Snapshots)

To use snapshots, add this repository to your Gradle config:

repositories {
    maven {
        url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
    }
}

Multiplatform Support

Clikt Testkit is a Kotlin Multiplatform library, currently supporting these targets:

  • JVM
  • Native (linuxX64, mingwX64, macosX64)