Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: No tests found

Tags:

When I am trying to run Android tests by executing:

./gradlew connectedDebugAndroidTest 

The following error occurs:

com.android.builder.testing.ConnectedDevice > 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 build.gradle or gradle-wrapper.properties files.

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.

like image 490
Andrii Abramov Avatar asked Mar 27 '17 08:03

Andrii Abramov


People also ask

What is filter includeTestsMatching?

includeTestsMatching. TestFilter includeTestsMatching​(String testNamePattern) Appends a test name pattern to the inclusion filter. Wildcard '*' is supported, either test method name or class name is supported. Examples of test names: "com.

What is useJUnitPlatform?

useJUnitPlatform() Specifies that JUnit Platform should be used to discover and execute the tests.

What is org JUnit Jupiter?

JUnit Jupiter is the combination of the programming model and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform. JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform.


2 Answers

One possible reason for this error message is that you get a crash in the app early in the test Runner. In such cases the exception stack will be in logcat but not in the gradle output.

like image 183
miguel Avatar answered Sep 21 '22 19:09

miguel


I had the issue, try upgrading the test runner. Upgrading it to 0.5 from 0.4.x solved it. Ensure you have these lines in your build.gradle:

androidTestCompile "junit:junit:4.12" androidTestCompile "com.android.support.test:runner:0.5" 
like image 34
jonduran Avatar answered Sep 21 '22 19:09

jonduran