11

I'm trying to update my project to recently released Android Test Support library version 1.0.0. But if I add assertj-core dependency Gradle instrumented test tasks start to fail with "No tests found" message. I can successfully run individual tests from IDE though.

It is easy to reproduce the problem:

  1. Create new project from Android Studio 3 with empty activity.
  2. Add assertj-core dependency.
  3. Run instrumentation tests from command line ./gradlew connectedDebugAndroidTest.

Gradle script.

android {
    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

dependencies {
    implementation 'com.android.support:appcompat-v7:26.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.0'
    androidTestImplementation group: "org.assertj", name: "assertj-core", version: "2.8.0"
}

Console output.

com.android.builder.testing.ConnectedDevice > No tests found.
[Nexus_4_API_25(AVD) - 7.1.1] FAILED 
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).

Tests successfully run if downgrade com.android.support.test:runner to previous version 0.5.

Sokolof
  • 2,271
  • 2
  • 19
  • 30
  • 1
    Have you tried compiling with [`assertj-core` version `3.8.0`](https://mvnrepository.com/artifact/org.assertj/assertj-core/3.8.0)? – azizbekian Aug 13 '17 at 16:51
  • @azizbekian with assertj 3.8 build fails with `com.android.dx.cf.code.SimException: default or static interface method used without --min-sdk-version >= 24`. I guess 3.x branch requires Java 8 features unsupported by android platform. I am targeting min API 15 btw. – Sokolof Aug 13 '17 at 17:15
  • try `org.junit.Assert`, `org.junit.Test`, `org.junit.runner.RunWith` ...and `@RunWith(AndroidJUnit4.class)`. – Martin Zeitler Jan 20 '18 at 00:11

1 Answers1

0

My test cases were not picked up unless the name at least one of them started with test.

I created a dummy ignored test case:

@Test
fun testDummy() {
    Assume.assumeTrue(false)
}
Eugen Pechanec
  • 37,669
  • 7
  • 103
  • 124