I am trying to test my code using Kotlin. When trying to import the kotlin.test
package, nothing appears.
Do I have to add the dependency somewhere first? And how can I run my unit test afterwards?
The kotlin.test
package is packaged in kotlin-test
module, so you need add the dependencies in your build.gradle
as below:
dependencies{
testCompile "org.jetbrains.kotlin:kotlin-test:$kotlin_version"
}
Beside that, you need to add an unit test framework in the build.gradle
like as junit-4
, for example:
dependencies{
testCompile "junit:junit:4.12"
}
How to write a JUnit Test? you can see it in junit.org as further.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With