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

Leave a Comment