anchor.diff:          MyApp.main();
       }
   }
  +----
  +
  +.Kotlin/Kotest
  +[source,kotlin,role=secondary]
  +----
  +import io.kotest.assertions.throwables.shouldThrow
  +import io.kotest.core.spec.style.StringSpec
  +import io.kotest.extensions.system.*
  +import io.kotest.matchers.shouldBe
  +// ...
  +
  +class SystemExitTest : StringSpec() {
  +
  +    override fun listeners() = listOf(SpecSystemExitListener)
  +
  +    init {
  +        "Picocli app should exit process with return code 42" {
  +            shouldThrow<SystemExitException> {
  +                main(arrayOf())
  +            }.exitCode shouldBe 42
  +        }
  +    }
  +}
  +
  +@Command
  +class PicocliApp : Callable<Int> {
  +    override fun call(): Int {
  +        return 42
  +    }
  +}
  +
  +fun main(args: Array<String>) : Unit = exitProcess(CommandLine(PicocliApp()).execute(*args))
   ----
   
   === Testing Environment Variables
  
positive.code: }
  ----
  
  ==== JUnit 4 and `ExpectedSystemExit`
  
  Applications that use JUnit 4 can use Stephan Birkner's https://stefanbirkner.github.io/system-rules[System-Rules] project for testing the https://stefanbirkner.github.io/system-rules/#ExpectedSystemExit[exit code].
  For example:
  
  [source,java]
  ----
  import org.junit.Rule;
  import org.junit.Test;
  
negative.code: 
  === Testing the Exit Code
  Testing the exit code of applications that call `System.exit` can be tricky but is not impossible.
  Depending on your programming language, your environment and your testing framework, you have several options: 
  
  * **Java 8**: You can use Stephan Birkner's https://github.com/stefanbirkner/system-lambda[System-Lambda] project for testing the https://github.com/stefanbirkner/system-lambda#systemexit[exit code]
  * **Java/Kotlin + Junit 5**: You can use Todd Ginsberg's https://github.com/tginsberg/junit5-system-exit[System.exit()] extension for Junit 5. The project README mentions common https://github.com/tginsberg/junit5-system-exit#use-cases[use cases].
  * **Java + Junit 4**: You can use Stephan Birkner's https://stefanbirkner.github.io/system-rules[System-Rules] project for testing the https://stefanbirkner.github.io/system-rules/#ExpectedSystemExit[exit code].
  * **Kotlin + Kotest**: Kotlin coders you may use the https://kotest.io/[Kotest] test framework which comes with https://kotest.io/docs/extensions/system_extensions.html#system-exit-extensions[System Exit extensions] that allow you to test the exit code.
  
  The listing below provides code samples for all of the four options mentioned above:
  
  .Java 8
  [source,java,role=primary]
  ----
  import static com.github.stefanbirkner.systemlambda.SystemLambda.catchSystemExit;
  // ...
  