Link Search Menu Expand Document

Kotlin Support

Requires pitest 1.9.5 or above.

Maven Central


Although Kotlin compiles to normal java bytecode, some language features require compiler generated constructs that do not map back to the source code. This results in confusing mutants that are hard to interpret, and junk mutations which cannot be reproduced by mistakes in the source code.

The kotlin plugin filters out these junk mutations and removes confusing noise from mutant descriptions.

Support is currently provided for the following language features

  • Coroutines
  • Destructuring
  • Intrinsics
  • Safe casts
  • Autogenerated accessors
  • Lateinit
  • Unmatched when clauses in enums and sealed classes
  • Var accessors
  • Inlined code
  • Non-null types

The plugin also filters equivalent mutants where pitest has introduced ‘empty’ returns into methods that already return empty collections using Kotlin library methods, and supports ‘empty’ return values for Kotlin specific types including

  • IntRange
  • LongRange
  • CharRange
  • Sequence
  • CoroutineContext

Inlined Functions

Inlined functions are a challenge for bytecode based mutation testing. When an inlined function is used, its bytecode is copied into the client class. This creates two problems

  • The client class contains instructions that do not map to its source code
  • The inlined function itself is never executed (instead copies of it are executed in various locations)

Since release 0.1.2 the Kotlin plugin addresses the first issue by filtering out mutations where it detects that the bytecode has been inlined. The second problem remains an issue if your codebase contains inline function definitions. These areas of code will appear to be uncovered by any test. Any mutants seeded into them will survive.


Before you can use the integration, you must first acquire a licence. Access to the kotlin plugin is automatically included with our Pro licence. If you don’t have a pro licence, and would like access to the beta e-mail us for a free licence.

The licence file must be named cdg-pitest-licence.txt and placed at the root of the project.

The plugin must be placed on the classpath of the pitest tool (not on the classpath of the project being mutated).

E.g for maven


Or for gradle

dependencies {
  pitest 'com.groupcdg.pitest:pitest-kotlin-plugin:0.2.2'

See gradle-pitest-plugin documentation for more details.