android-instrumentation

Running instrumentation tests from specific package via spoon-gradle plugin

懵懂的女人 提交于 2019-12-05 15:59:14
I am using spoon-gradle-plugin from Roman Mazur. I am capable of running all tests at once but I am having trouble to specify "group" of tests that I would like to launch. Currently my spoon setup looks like that: spoon { debug = true baseOutputDir = file("$buildDir/spoon-log") if (project.hasProperty('spoonClassName')) { className = project.spoonClassName if (project.hasProperty('spoonMethodName')) { methodName = project.spoonMethodName } } adbTimeout = 60 * 60; } My tests are located in packages: And my goal is to create separate gradle tasks that are depending on spoon to launch tests from

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

▼魔方 西西 提交于 2019-12-05 10:04: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.gradle file: apply plugin: 'com.android.application' android { compileSdkVersion 18 buildToolsVersion "21

Wait until view become visible with IdleResource

徘徊边缘 提交于 2019-12-05 02:44:18
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 what am I doing wrong. I have written such IdleResource: public class AmountViewIdlingResource

Where is the output from an android instrumented test?

我与影子孤独终老i 提交于 2019-12-05 00:28:28
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? Running gradlew connectedCheck will generate test results in the build directory, see \build\reports\androidTests\connected\ and \build\outputs\androidTest-results\connected\ These instrumentation tests will also log their output in LogCat, along with

How to check expected intent sent without actually launching activity in Espresso?

杀马特。学长 韩版系。学妹 提交于 2019-12-04 19:10:26
问题 I have a UI test which clicks a button, and then launch a new Activity in its onClickListener. The test checks whether expected intent is sent or not. My problem is, I want to test whether expected intent is sent without actually launching the activity . Because I found that new activity initializes its state, and it makes subsequent tests flaky. I know there are two Espresso Intents api, which are intended and intending , but both fail to meet my needs. intended api actually launches the

Cannot resolve ActivityTestRule after upgrading dependencies. Unable to import ActivityTestRule

人盡茶涼 提交于 2019-12-04 17:03:43
问题 I have written instrumentation tests which was working fine, but now getting error cannot resolve ActivityTestRule error after upgrading dependencies to androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' I am using android support version 27.1.1 It is working fine with dependencies androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test

How to mock two APIs with MockWebServer Android test cases

允我心安 提交于 2019-12-04 05:43:27
问题 I am performing instrumentation testing, in that I am invoking one of the activities which call 2 APIs when activity is created. Now I want to write instrumentation test cases for this activity, where I have to mock the API response with mockWebServer of mockito. My mocking code works fine when I call one single API, but it fails when two APIs are getting called simultaneously. Even there is another scenario let's say, we have API to fetch recent message data , but before that, we always

“No tests found” for instrumentation tests for Lollipop and above

倖福魔咒の 提交于 2019-12-04 00:28:49
My instrumentation based (espresso) tests don't run on Lollipop+ devices and emulators. They correctly run on any other platform. I have the same symptoms as the guy in this thread - https://groups.google.com/forum/?fromgroups#!topic/adt-dev/QW5SuzQizNk My tests are in src/androidTest/java/ I've set testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' The test classes are @RunWith(AndroidJUnit4.class) Individual tests are annotated with @Test I can execute a ./gradlew connectedCheck and the tests run well on a device with KitKat, but when I try to run the same tests the

How to place Android (instrumentation) test files outside of project directory?

纵饮孤独 提交于 2019-12-04 00:26:38
问题 I have an Android project (generated by Cordova) that I want to add (instrumentation) tests to. It has only one MainActivity.java that should be tested. Normally this means adding some dependencies to build.gradle and creating a file /src/androidTest/java/org/example/package/MainActivityTest.java with an MainActivityTest class and some test methods. (In Android Studio I can even generate those by using Run -> "Record Espresso Test" - so really simple and works). Unfortunately, I now have the

Run all unit tests in Android Studio

陌路散爱 提交于 2019-12-03 18:00:23
问题 I have this project in Android Studio : I wish to run all unit tests in all project with one click. How i can do it ? 回答1: First, you can list all the test tasks available in your project with ./gradlew tasks Then you can choose the tasks you want to execute. If you want to execute all tests for all flavors ans all buildTypes, you just have to run ./gradlew test connectedAndroidTest If you don't want to remember all the gradle test command each time you want to run the tests, you can create a