In my case using Android Studio 3.1.1, my Run/Debug Configurations were incorrect, probably due to to an automatic conversion of the config when updating Android Studio. My instrumented test config ended up being placed under "Android JUnit" configs, instead of "Android Instrumented Tests". Creating a new instrumented tests config for my particular class worked.
Also, the default configs created when right-clicking on my module's "Run All Tests" option fail to find my instrumented tests and run properly, resulting in
0 test classes found in package '<default package>'
Process finished with exit code 254
Empty test suite.
as the default config created popped up under Android JUnit. However, right-clicking on my package containing my instrumented tests creates it in the right category. I can also manually edit it to 'All in Module' and still execute my kotlin tests properly.
As an aside, I've also had the IDE give me the following misleading output before:
$ adb shell am instrument -w -r -e package com.base.package.kotlintests -e debug false com.base.package.test/android.support.test.runner.AndroidJUnitRunner
Client not ready yet..
Started running tests
Tests ran to completion.
Empty test suite.
Why did it say there was an empty test suite why I clearly have tests? Looking at the logs or running the adb
command on a terminal revealed that my code was throwing an exception in my @BeforeClass
setup! So no tests were executed, and everything completed trivially.
apply plugin: 'kotlin-android'
– Dmitry