vendredi 11 août 2017

connectedAndroidTest on multidex app is not finding any tests

I am trying to automate my build and make running our acceptance tests a part of that.

Unfortunately the gradle task connectedAndroidTest is reporting

Starting 0 tests on Nexus_5X_API_25(AVD) - 7.1.1

com.android.builder.testing.ConnectedDevice > No tests found.[Nexus_5X_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).

This does not happen when I run the tests/suite from the IDE.
I found that Android Studio is executing following commands:

$ adb push /path/to/apk/app-debug.apk /data/local/tmp/com.MyApp
$ adb shell pm install -r "/data/local/tmp/com.MyApp"

$ adb push /path/to/apk/app-debug-androidTest.apk /data/local/tmp/com.MyApp.test
$ adb shell pm install -r "/data/local/tmp/com.MyApp.test"

$ adb shell am instrument -w -r  -e debug false -e class com.myapp.TestSuite http://ift.tt/2hPJy7J

I know what those commands do but I do not know what connectedAndroidTest is doing under the hood and why it fails.

I found out that the issue has to do with multidex. At the end of the official page about enabling multidex it reads:

Notes:
* Don't use MultiDexTestRunner, which is deprecated; use AndroidJUnitRunner instead.
* Using multidex to create a test APK is not currently supported.

I do not understand what is mean with create test APK and why the adb command works.
I do not want to run the adb commands by hand as they have no reporting built in and I would need to do this all myself.

Is there any way to use connectedAndroidTest with multidex apps?

Aucun commentaire:

Enregistrer un commentaire