Libraries for Kotlin & JVM Testing

|


I’ll be updating this entry with new libraries and version updates. To make sure that you don’t miss anything, subscribe to newsletter and bookmark this page.

Frameworks

JUnit4

project website

dependencies {
    testImplementation "junit:junit:4.13.2"
}

JUnit5

project website

test {
    useJUnitPlatform()
}

dependencies {
	testImplementation "org.junit.jupiter:junit-jupiter:5.8.0"

}

Junit4 & Junit5 in one project

Add junit vintage

test {
    useJUnitPlatform()
}

dependencies {
    testImplementation "org.junit.jupiter:junit-jupiter:5.8.0"
    testImplementation "junit:junit:4.13.2"
    testImplementation "org.junit.vintage:junit-vintage-engine:5.8.0"
}

Kotest

project website

test {
  useJUnitPlatform()
}

dependencies {
  testImplementation 'io.kotest:kotest-runner-junit5:5.0.0>'

}

Spring Boot Starter Test

dependencies {
	testImplementation 'org.springframework.boot:spring-boot-starter-test'

}

Mocking

Mockito

project website

dependencies{
    testImplementation 'org.mockito:mockito-core:4.1.0'
}

Mockito-Kotlin

project website

dependencies{
    testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:4.0.0"
}

MockK

project website

dependencies {
   testImplementation 'io.mockk:mockk:1.12.1'
}

Assertions

Kotest

dependencies {
  //assertions
  
  testImplementation 'io.kotest:kotest-assertions-core:5.0.0' 
  //property testing
  
  testImplementation 'io.kotest:kotest-property:5.0.0' 
}

Strikt

project website

dependencies {
	testImplementation "io.strikt:strikt-core:0.33.0"
}

AssertJ

project website

dependencies {
	testImplementation 'org.assertj:assertj-core:3.21.0'
}

Truth

dependencies {
	testImplementation 'com.google.truth:truth:1.1.3'
}

Join AndroidPro newsletter & get roadmap for Android devs

👉 Architecture
👉 CI/CD
👉 Testing
👉 Compose
👉 projects to learn from
… in a single document


Read more:

  • #kotlinDevChallenge – 10

    #kotlinDevChallenge – 10

    Implement a function that sums the first 5 even numbers from each of three given integer Flows and returns their total sum. Properly handle…

  • #kotlinDevChallenge – 9

    #kotlinDevChallenge – 9

    Write a function that takes a list of lists of integers and returns a single list containing all unique elements. Ensure that the resulting…

  • #kotlinDevChallenge – 8

    #kotlinDevChallenge – 8

    data class A is given. We create an instance of this class and then call the .copy() function. What will be printed out? Mark…