android-instrumentation

Reset app state between InstrumentationTestCase runs

那年仲夏 提交于 2019-12-03 15:54:13
问题 One of my QA engineers is supporting an app with a fairly large codebase and a lot of different SharedPreferences files. He came to me the other day asking how to reset the application state between test runs, as if it had been uninstalled-reinstalled. It doesn't look like that's supported by Espresso (which he is using) nor by the Android test framework natively, so I'm not sure what to tell him. Having a native method to clear all the different SharedPreferences files would be a pretty

Check fragment visibility after clicking on Tab from TabLayout that only contains icon using Android Espresso

拟墨画扇 提交于 2019-12-01 20:33:50
I'm trying to check if my fragment is visible after performing a click on my tab from my tabLayout which has been set up with view pager. This is my actual activity code, inside my activity onCreate method: mViewPager = findViewById(R.id.contentFrameLayout); mViewPager.setAdapter(mSectionPageAdapter); mViewPager.setPagingEnabled(false); //Set up the tab layout to display tabs tabLayout = findViewById(R.id.homeTabs); tabLayout.setupWithViewPager(mViewPager); for (int i = 0; i< tabLayout.getTabCount(); i++) { TabLayout.Tab mTab = tabLayout.getTabAt(i); if (mTab != null) { switch (i){ case 0:

Flavors and instrumentation tests - gradle configuration

╄→гoц情女王★ 提交于 2019-12-01 12:16:51
I use flavors in my project and I wanna add add instrumentation tests specific for each flavor. So I created MyApplication/src/androidTestFlavor1/java/com.package.test MyApplication/src/androidTestFlavor2/java/com.package.test But it doesn't work correctly. So, I've tried to configure it in build.gradle, I've added android { ... sourceSets { flavor1{ instrumentTest.setRoot('src/instrumentationTestFlavor/java') } } ... } but I get error: Error:(59, 0) Could not find property 'instrumentTest' on source set ding. What's the best solution here? When you setup a new project in android studio it

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

戏子无情 提交于 2019-12-01 02:54:28
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 requirement that those test files do actually live outside the project directory. There should be only

Drag & Drop Espresso

痞子三分冷 提交于 2019-11-30 19:09:11
Is it possible to perform drag & drop action via Espresso? I need to move one view down (in straight line) in order to accept some conditions in my automation test. You can use GeneralSwipeAction to perform drag & drop. public static ViewAction swipeUp() { return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.BOTTOM_CENTER, GeneralLocation.TOP_CENTER, Press.FINGER); } You can customize the location to meet your requirement as well. Thats how I have done it. You have more access to what should happen with your view like that. But accepted answer perform drag&drop too. public static void

Android Studio Instrumentation testing build variant

自作多情 提交于 2019-11-30 08:06:01
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 to find instrumentation target package: com.teamtreehouse.review.debug However when I try to run my

Drag & Drop Espresso

人走茶凉 提交于 2019-11-30 03:15:05
问题 Is it possible to perform drag & drop action via Espresso? I need to move one view down (in straight line) in order to accept some conditions in my automation test. 回答1: You can use GeneralSwipeAction to perform drag & drop. public static ViewAction swipeUp() { return new GeneralSwipeAction(Swipe.FAST, GeneralLocation.BOTTOM_CENTER, GeneralLocation.TOP_CENTER, Press.FINGER); } You can customize the location to meet your requirement as well. 回答2: Thats how I have done it. You have more access

No error still Android Studio says “no tests were found”

99封情书 提交于 2019-11-29 10:23:51
I am trying to write an instrumentation test for my MainActivity. I followed the answers given here . Still Android Studio cannot find any tests. I have the class ApplicationTest.java in the androidTest folder. Here's the contents of the class: package com.example.monicamarcus.mymusicplayer import android.app.Activity; import android.test.ActivityInstrumentationTestCase2; import com.example.monicamarcus.mymusicplayer.MainActivity; public class ApplicationTest extends ActivityInstrumentationTestCase2<MainActivity> { public ApplicationTest() { super(MainActivity.class); } public void

How to disable animations in code when running Espresso tests

江枫思渺然 提交于 2019-11-29 09:31:25
问题 Has anybody managed to disable animations through code when running Espresso tests? I've been trying to follow the instructions in this webpage (linked to from here): https://code.google.com/p/android-test-kit/wiki/DisablingAnimations Unfortunately it does not appear to be working, as I keep seeing this permissions error: 04-27 15:48:28.694 303-342/system_process W/PackageManager﹕ Not granting permission android.permission.SET_ANIMATION_SCALE to package com.cookbrite.dev (protectionLevel=50

The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin

倾然丶 夕夏残阳落幕 提交于 2019-11-29 01:23:21
问题 I updated the AndroidStudio to version 3.1 Clean Project... and build failed The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something? However, the 3.0.1 version of AndroidStudio does not have this problem Detailed log: org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':ios_dialog_lib'. at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java