Let's build a Firefox extension with Kotlin

Android Test with Kotlin

Android Testing using Kotlin





Many developers are quite optimistic about Kotlin future for Android. It sounds so sweet: less verbose, more type-safety, zero-overhead null-safety, Java interop. But not everyone is ready to take a risk and start writing production code using new programming language. Indeed, it could be not mature enough and will add dependencies which increase method count of APK for more than 6.5K

But what if we’ll use Android testing using Kotlin?

Project setup

So we can setup Kotlin plugin and related libraries to be only in testCompile dependencies scope. Here is what we should set in build.gradle:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.2.0'

testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_ver"
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_ver"
}
Another important detail in build.gradle is setting proper source sets to make Kotlin tests folders visible to compiler and IDE.

Source: How to do Android Testing using Kotlin

Comments