Can I use kotlintest for Espresso tests? Is there ...
# kotlintest
l
Can I use kotlintest for Espresso tests? Is there any good sample code?
w
Afaik you can’t. Since Espresso (as well as Robolectric) use a JUnit4 runner, you can’t use them with KotlinTest which is based on JUnit5
l
Yes you can.
I've been testing with Espresso and Robolectric
Roboletric isn't rady yet, but espresso tests need no additional setup as far as I've tested
😲 1
w
What’s the difference? Don’t both instrumented tests and Robolectric tests use the same runner?
Is there any sample/documentation yet?
l
No
Robolectric has it's own runner
But Android runs on JUnit
There is no official documentation, but I'm tinkering with my personal project and this will be in KotlinTest for 4.0
Example class for Espresso test
In the same app there is a very alpha version of the Robolectric runner that we have been building
w
Is there no additional configuration there? 😮 It just has
androidx.test.runner.AndroidJUnitRunner
configured in the manifest and that’s it?
this will be in KotlinTest for 4.0
So it doesn’t work in 3.x yet? Can you tell me what was the required change(s) to make it work?
l
It does work
I really didn't do any change... It was actually funny, I was experimenting on what I needed to do for UI testing and... It was already done
It uses the default AndroidJUnitRunner which delegates to JUnit. The KotlinTest JUnit5 runner works
Robolectric requires configuration tho
But be careful. We are not completely sure on how everything works, so treat everything as experimental
👍 1