android-perftracking
android-perftracking copied to clipboard
[Android][Test] Setup Kotlin for tests
So it looks like we can't use spek because it doesn't work with robolectric see issue #65. Same goes for KotlinTest, see issue #189.
With these limitations I think we can improve the tesk code base with the following setup: Kotlin + junit4 + robolectric + kluent
Hey! I know this issue is a little bit old, but we just added Robolectric experimental support to KotlinTest.
Perhaps this is what you need for now https://github.com/kotlintest/kotlintest/pull/1014
@Kerooker I have been trying to use the Robolectric support but I get some issues. Please, can you provide the steps to configure it, including the dependencies? Thanks.
Sure! I know this will be a little bit complicated right now, as we are experimenting a lot, but it should work:
First add the snapshot repository to your repositories:
repositories {
maven(url = "https://oss.sonatype.org/content/repositories/snapshots/")
}
Then add the Robolectric Extension dependency to your dependencies:
dependencies {
testImplementation("io.kotlintest:kotlintest-extensions-robolectric:4.0.2653-SNAPSHOT")
}
Then in your tests that are going to use Robolectric, annotate them with @RobolectricTest.
To get robolectric working, you finally need to add it to your project config (if you don't know how to do that, take a look here)
override fun extensions() = listOf(RobolectricExtension())