No tests found in <package> when testing with Espresso
Set the instrumentation runner
Add to the same build.gradle file the following line in android.defaultConfig: testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
apply plugin: 'com.android.application'
android {
...
defaultConfig {
...
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}
dependencies {
// App's dependencies, including test
compile 'com.android.support:support-annotations:23.0.1'
...
}
I never used Espresso Intents but perhaps you need this like here:
Use IntentsTestRule instead of ActivityTestRule when using Espresso-Intents. IntentsTestRule makes it easy to use Espresso-Intents APIs in functional UI tests. This class is an extension of ActivityTestRule, which initializes Espresso-Intents before each test annotated with @Test and releases Espresso-Intents after each test run. The activity will be terminated after each test and this rule can be used in the same way as ActivityTestRule.
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
were missing
In 2020 you might want to use this newer AndroidX (jetpack) test runner.
android {
...
defaultConfig {
...
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
}