android-instrumentation

Run an instrument test from within app and wait for result

三世轮回 提交于 2021-02-07 11:15:43
问题 I am developing a QA automation solution that can record/playback QA tests on Android. A key business requirement is to have no dependency on a connected PC while playing back the recorded test. To that end, I'm trying to run an Instrumentation test without a connected PC. (Specifically, an Appium UiAutomator2 test). My current approach is trying to run the test programmatically from my app. If I were running the test normally from a connected PC, I would use the command adb shell am

Android Instrumental Test running on Emulator but not on real device

耗尽温柔 提交于 2021-01-29 15:05:40
问题 I am trying to run android Instrumental Test it seem running on emulator gives test result but on real device its not working and output is "Test running failed: No test results" Below is my build.gradle file apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "my.app" minSdkVersion 18 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx

Android Test cases not working in debug mode

那年仲夏 提交于 2020-12-30 08:01:03
问题 I am not able to debug android Instrumentation test cases (using espresso & UiAutomator) But earlier test cases the debugging was working fine but with recent update it is not working anymore. It gets always struck up at instantiating unit test I can see in command window that it's trying to launch PACKAGE_NAME**.test** adb shell am instrument -w -r -e debug true -e class PACKAGE_NAME.LanguageScreenTest#testSelectImportant PACKAGE_NAME**.test**/android.support.test.runner.AndroidJUnitRunner

How to grant permissions to android instrumented tests?

走远了吗. 提交于 2020-08-02 06:16:32
问题 I have an application that reads SMSs. The app works fine when debugging but when testing it using android instrumented test it throws the following error java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider This is my test case @RunWith(AndroidJUnit4.class) public class SmsFetcherTest { @Test public void fetchTenSms() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getContext(); // Fails anyway.

How to grant permissions to android instrumented tests?

拟墨画扇 提交于 2020-08-02 06:16:15
问题 I have an application that reads SMSs. The app works fine when debugging but when testing it using android instrumented test it throws the following error java.lang.SecurityException: Permission Denial: reading com.android.providers.telephony.SmsProvider This is my test case @RunWith(AndroidJUnit4.class) public class SmsFetcherTest { @Test public void fetchTenSms() throws Exception { // Context of the app under test. Context appContext = InstrumentationRegistry.getContext(); // Fails anyway.

annotationProcessor + androidTest + dagger2

最后都变了- 提交于 2020-03-18 11:17:57
问题 For instrumented tests, I have a TestApplication that creates a TestComponent , but the file is not generated anymore ( Error:/xxx/TestApplication.java:16: The import.xxx.DaggerTestApplicationComponent cannot be resolved ). I'm not able to identify the root cause. I've tried different Android Studio (2.2, 2.1.2), different gradle plugin (2.2.0-alpha6, 5, 4) and different versions of dagger (2.2 to 2.6). Should I use androidTestAnnotationProcessor ? (that was not the case before) edit: to use

Android Studio Instrumentation testing build variant

扶醉桌前 提交于 2020-01-29 02:39:50
问题 So I am trying to write instrumentation tests using a custom build variant, mock. In this build variant I mocked up my classes and server. When I try using the mock build myself it works fine, but I can't seem to use my mock build for testing. Here's what my configuration looks like inside Android Studio. I had some issues getting my tests to run so I tried to uninstall all versions of my app except my mock version and I keep getting this error: Test running startedTest running failed: Unable

Android Studio + Gradle and AndroidTest res/raw

ぐ巨炮叔叔 提交于 2020-01-17 02:53:08
问题 I have an Android app. And I want to write instrumentation tests. I want to put some specific files in the res/raw folder for the test apk. I place them in the androidTest/src/res/raw folder and reference them in code with R.raw.file . However the app references some other resource file, which one in my main source set. How can I ensure that my test apk gets the proper files from its own res/raw folder? 回答1: Your path is wrong. The path you want is src/androidTest/res/raw . Files in this