android-instrumentation

connectedAndroidTest on multiple emulators

自闭症网瘾萝莉.ら 提交于 2019-12-10 12:34:54
问题 Background I want to run my Android Instrumented tests on Jenkins on different emulators. Say I have 100 tests and 4 emulators, I want to run 25 tests on each. I perform ./gradlew connectedDebugAndroidTest in Jenkins Pipeline's parallel for 4 emulators stage('Instrumented Tests') { parallel( emu1: { runInstrumentedTestOnEmu(...) }, emu2: { runInstrumentedTestOnEmu(...) } ... ) } connectedDebugAndroidTest will spawn other commands in order to setup the environment for running instrumented

Sharing resources across unit tests and instrumentation tests in Android

陌路散爱 提交于 2019-12-08 18:37:53
问题 Now that Google has added experimental unit test support, how might one go about sharing resources across both unit tests and instrumentation test? For example, say I have a TestUtils.java class that I want accessible in both my unit tests and my instrumentation tests. If I put it in my src/test/java folder, it will be accessible to my unit tests. If I put it in my src/androidTest/java folder, it will be accessible to my instrumentation tests. How do I make it accessible to both? The only

Unable to find instrumentation info for: ComponentInfo{../android.support.test.runner.AndroidJUnitRunner}

筅森魡賤 提交于 2019-12-08 01:32:57
问题 I have written a simple Android instrumental test case to test networking operation. Test case class name: Main3ActivityTest.java Method name:addNewEmployee I run my test case using command line then I got following exception. Command: ./adb -s emulator-5554 shell am instrument -w -r -e class murali.myapplication.Main3ActivityTest#addNewEmployee murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner Issue: INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION

Android Unit test with Volley

余生长醉 提交于 2019-12-07 14:18:23
问题 Is it possible to write a unit test for my android application where I use Volley for network request. For Eg. I want to write a unit test for a log in feature where in I post a volley request with users credentials and check for a valid user Object in the response. Has anyone done anything similar? Kindly provide examples or references. This is my login method: public void login() { try { JSONObject jsonRequest = new JSONObject(); String emailString = email.getText().toString(); jsonRequest

Instrumentation run failed due to 'Process crashed.' after long tests execution

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 05:30:19
问题 I have about 700 tests to execute. When I run them all, there raised a crash "Instrumentation run failed due to 'Process crashed.'" Check device logcat for details. Test running failed: Instrumentation run failed due to 'Process crashed.' after some time of execution, about 10 minutes and ~360-370th executed test. Logcat doesn't contain any information about this crash It is applicable by running from Android Studio, from cmd (on PC and Mac). Device used - Samsung S3 on Android 4.1.1 build

Wait until view become visible with IdleResource

瘦欲@ 提交于 2019-12-06 23:08:53
问题 I am writing Instrumentation tests with usage of Espresso 2.2. Flow I want to test: radioButton clicked by test onClick launches request to API after every time different time I receive response positive response triggers interface method that is called in activity onRequestSuccess I am making additional panel on screen named vSetupAmount visible I want to register IdleResource after click on radioButton so it waits until vSetupAmount becomes visible. But I can't make it work. Please tell me

Where is the output from an android instrumented test?

南笙酒味 提交于 2019-12-06 18:39:27
问题 I managed to get gradle cC to work. My test just prints out and logs one line of text. grep -r text * fails. where is the system.out and logging output? thanks edit: i found the output for the unit tests (it's in .../app/build/test-results/). but still no luck with the other. is there a way to save the output from the instrumented tests somehow? 回答1: Running gradlew connectedCheck will generate test results in the build directory, see \build\reports\androidTests\connected\ and \build\outputs

Unable to find instrumentation info for: ComponentInfo{../android.support.test.runner.AndroidJUnitRunner}

こ雲淡風輕ζ 提交于 2019-12-06 13:05:07
I have written a simple Android instrumental test case to test networking operation. Test case class name: Main3ActivityTest.java Method name:addNewEmployee I run my test case using command line then I got following exception. Command: ./adb -s emulator-5554 shell am instrument -w -r -e class murali.myapplication.Main3ActivityTest#addNewEmployee murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner Issue: INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{murali.myapplication.test/android

Android Unit test with Volley

牧云@^-^@ 提交于 2019-12-05 21:03:53
Is it possible to write a unit test for my android application where I use Volley for network request. For Eg. I want to write a unit test for a log in feature where in I post a volley request with users credentials and check for a valid user Object in the response. Has anyone done anything similar? Kindly provide examples or references. This is my login method: public void login() { try { JSONObject jsonRequest = new JSONObject(); String emailString = email.getText().toString(); jsonRequest.put("email", emailString); String passwordString = password.getText().toString(); jsonRequest.put(

How to regain Access on a Activity after sending it to background

假装没事ソ 提交于 2019-12-05 19:22:59
With Espresso I try to test sending an Activity to background, with the Home button and then getting it up in the foreground again to make some checks: @EspressoTest public void test() { onSomeView().check(matches(isDisplayed())); getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); Context context = getInstrumentation().getTargetContext(); Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); onSomeView().check(matches(isDisplayed())); } I had to use intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);