android-testing

Gradle: Resolved versions for app and test app differ

…衆ロ難τιáo~ 提交于 2019-12-10 21:49:46
问题 When I add the dependency: compile 'net.bytebuddy:byte-buddy-android:0.7.8' in my app, I get this error: Conflict with dependency 'net.bytebuddy:byte-buddy'. Resolved versions for app (0.7.8) and test app (0.6.14) differ. See http://g.co/androidstudio/app-test-app-conflict for details. I have visited http://g.co/androidstudio/app-test-app-conflict and it says: Gradle build will fail if the main APK and the test APK use the same library (e.g. Guava) but in different versions.[...] To make the

Testing a click on an Android ListView with ActivityUnitTestCase

不打扰是莪最后的温柔 提交于 2019-12-10 19:00:52
问题 I have implemented a ListView that starts a new Activity when a list item is clicked. When I test it manually, it works perfectly. But when I try to do an automated test with ActivityUnitTestCase , I get a NullPointerException as though the ListView was empty. MainActivity (partial): public class MainActivity extends ListActivity { @Override protected void onResume() { super.onResume(); String[] items = new String[] {"item 1", "item 2"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>

Java.lang.NoClassDefFoundError with Espresso and Proguard

女生的网名这么多〃 提交于 2019-12-10 18:24:05
问题 I'm not very experienced with Espresso, but I finally succeed to run it. I have an app that need to be shrink by Proguard in order to be under the 56K methods. The app starts with a 3 sec animation, so I need to wait until this animation is over in order to continue. This is what I tried to do with the method waitFor(long delay) I tried to put this method as a standalone class, inner class and even project class = same error. Here is the Proguard file: android { ... compileSdkVersion ANDROID

Android automation using espresso without the app source code

荒凉一梦 提交于 2019-12-10 16:53:24
问题 Is it not possible to automation android app using espresso without source code. Gradle expects a structure like this: src/main/ src/androidTest/ But I would like to run these automation tests on a different version of the app? Is this possible just by installing the app and running the tests? Here it says its not possible: Automation of Android APK with Espresso 回答1: The answer is yes, you can run automation test using Espresso without app source code. Espresso is based on Android

Android tests are not executed

谁说我不能喝 提交于 2019-12-10 16:12:50
问题 I have created a test project with exact the same code as shown here: http://developer.android.com/tools/testing/testing_ui.html I have uploaded the jar file in the android virtual device and now I'm ready to run the tests. But I always get this output on the console: INSTRUMENTATION_STATUS: stream= Test results for WatcherResultPrinter= Time: 0.0 OK (0 tests) INSTRUMENTATION_STATUS_CODE: -1 I have also created a simple test with the following code: public void FailedTest() throws

How to run Uiautomator tests in to multiple devices?

空扰寡人 提交于 2019-12-10 15:33:26
问题 I am trying to Uiautomator android Ui tests in a .bat file. but i could not able them run parallelly. Here is my execution flow and have connected 3 devices -> adb devices XXXX XXXX XXXX -> adb push ./bin/UiautomatorTests.jar /data/local/tmp/ -> adb shell uiautomator runtest UiautomatorTests.jar -c com.music.tests Here how can i give a common common command for all the devices to runs with parllely 回答1: You can checkout Uiautomator-bot as it seems to fit your requirement. It can run

Continue Android tests after an exception

℡╲_俬逩灬. 提交于 2019-12-10 14:47:08
问题 When running my test suite in Android Studio, occasionally there will be an exception thrown from somewhere in my code (not in the test) which will cause the current test to fail (good because the test has found a bug) and the rest of the tests to stop running (not so good). I'd like the tests to continue running so that the entire suite finishes. Is this possible? 回答1: it is not possible by concept of INTERPRETER and COMPILER. Android uses jvm(java virtual machine) and JIT (just in time)

how to JUnit test IntentService

社会主义新天地 提交于 2019-12-10 14:11:11
问题 I'm new into Android testing, I want to test an IntentService and I'm currently extending ServiceTestCase. I'm trying to use a ResultReceiver but the problem is that OnReceiveResult is never called within the test case. (I also tried creating the ResultReceiver with new Handler() as the argument insetad of null but with the same result. what am I doing wrong? what is the proper way to test an IntentService ? this is the service: public class MyService extends IntentService { public MyService(

AndroidViewModel and Unit Tests

旧城冷巷雨未停 提交于 2019-12-10 13:31:21
问题 I am using AndroidViewModel with LiveData to send Intents to a IntentService and receiving events from an EventBus. I need the Application Context for the Intents and the EventBus. What is the best way to test AndroidViewModel classes with local tests? I can get it to start with Robolectrics RuntimeEnvironment.application but there doesnt seem to be a shadowOf() for AndroidViewModel to check if the right Intents were sent to the correct receiver. Perhaps it is somehow possible to do this with

espresso onView inconsistent performance

霸气de小男生 提交于 2019-12-10 12:51:48
问题 I am using Junit4 and Espresso for my tests. I am facing a weird issue with espresso tests - when I call onView sometimes everything is executed like it is supposed to, but sometimes my test freezes and after 60 seconds I get something like this "android.support.test.espresso.AppNotIdleException: Looped for 63 iterations over 60 SECONDS. The following Idle Conditions failed ASYNC_TASKS_HAVE_IDLED" For example : onView(withId(R.id.zone_button_continue)).perform(click()); onView(withId(R.id