Andrii Abramov Andrii Abramov - 11 months ago 174
Android Question

Gradle: No tests found

When I am trying to run Android tests by executing:

./gradlew connectedDebugAndroidTest

The following error occurs: > No tests found.[devicename] 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).
:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

I have not made any changes to

The issue can't be solved by updating everything to the latest version (gradle, android plugin, build tools, etc.)

All tests were previously successful. What could cause this mystic regression? Thanks.

Answer Source

I find this confusing that this error is also shown when the exception is thrown in @BeforeClass method.

public class DummyTest {

    public static void setUpClass() {
        throw new RuntimeException("Dummy error");

    public void lalks() throws Exception {

Output via adb:

Running tests

$ adb shell am instrument -w -r -e debug false -e class com.example.test.DummyTest com.example.test/
Client not ready yet..
Started running tests
Tests ran to completion.

Output via gradle:

Starting 1 tests on Nexus 5X - 7.1.1

junit.framework.TestSuite$1 > warning[Nexus 5X - 7.1.1] FAILED
        junit.framework.AssertionFailedError: No tests found in com.example.test.DummyTest
        at android.test.AndroidTestRunner.runTest(
:connectedAppDebugAndroidTest FAILED

If there is not exception thrown in @BeforeClass method everything will be fine.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download