android-testing

Dagger dependencies when overriding graph with mock module causes NoClassDefFoundError

爱⌒轻易说出口 提交于 2019-12-13 17:18:49
问题 I am am migrating project to dagger 1.2.2. I'd like to override some dependencies for functional tests. For that I included the dagger-compiler as a dependency of the androidTest-build(?) as well: apt "com.squareup.dagger:dagger-compiler:$daggerVersion" compile "com.squareup.dagger:dagger:$daggerVersion" androidTestApt "com.squareup.dagger:dagger-compiler:$daggerVersion Now the compiler complains that he cannot find a class (I guess because both builds now contain the transitive dependencies

java.lang.NoSuchMethodError: No interface method onTransitionToIdle()V

无人久伴 提交于 2019-12-13 15:00:18
问题 PLease i am new to Android Testing, i have being trying to fix an initial NavigationView Test bu i am getting the error. I was just trying to open the drawer and click a menu to go to a new activity. java.lang.NoSuchMethodError: No interface method onTransitionToIdle()V in class Landroid/support/test/espresso/IdlingResource$ResourceCallback; or its super classes (declaration of 'android.support.test.espresso.IdlingResource$ResourceCallback' appears in /data/app/com.bellman.inecparrot.mock-2

how to set up a Appium UI test maven project to work with Gitlab CI to test Android App?

纵饮孤独 提交于 2019-12-13 12:29:05
问题 I am an intern now, new to automation test.My goal here is to help my company set up CI for client side. Right now I have a maven project contains several tests using Appium java-client lib, under Eclipse IDE, which could run the UI tests locally. My goal next step is to hook my tests with the gitlab repo(which is already there, created by the android developers), but I am stuck here. Could somebody help me out? Please try to be specific: how should I set up the .gitlab.yaml? can we just have

Android Testing: Inflate and Display a custom Toast from Instrumentation

帅比萌擦擦* 提交于 2019-12-13 05:04:15
问题 I am trying to display a custom Toast but doing so from my automated test rather than from the application itself. The layout inflation does not work though. Is it even possible to inflate views and from the test project and display those? What does work is a standard Toast: final Activity targetActivity = Solo.getCurrentActivity(); // Using Robotium to get current displayed Activity Toast.makeText(targetActivity, "Hello from Instrumentation", Toast.LENGTH_SHORT).show(); What does NOT work is

configure Robolectric to write logs (tests output) into external file

大兔子大兔子 提交于 2019-12-13 03:44:29
问题 I'm adding the following code to build.gradle : android{ testOptions { unitTests.all { systemProperty 'robolectric.logging', '/path/to/file/robolectric.log' systemProperty 'robolectric.logging.enabled', 'true' } } } The file /path/to/file/robolectric.log has 777 permissions. The robolectric.logging.enabled=true is working because I started to see the output when I had configured with robolectric.logging=stdout (like here) Questions: 1) How to configure Robolectric to write the output into a

Android unit test Robolectric Maven : The method buildActivity(Class<MyActivity>) is undefined for the type Robolectric

 ̄綄美尐妖づ 提交于 2019-12-13 02:30:09
问题 I am trying to creat some tests for my android application in Maven/Eclipse with Roboelectric. I have an error in the method buildActivity() from the Robolectric class: The method buildActivity(Class<MyActivity>) is undefined for the type Robolectric This is how I am calling it : @Before public void setup() { activity = Robolectric.buildActivity(StartActivity.class).create() .get(); } And this is my dependency in POM.xml : <dependency> <groupId>org.robolectric</groupId> <artifactId

How to use MediaMuxerTest (a AndroidTestCase file)

陌路散爱 提交于 2019-12-13 02:17:02
问题 I find demo for MeediaMuxer, which is a AndroidTestCase File. Here is the link. I never used Android Test. I did some research, but most of them are somehow a little complex... It seems like that I need a xml file, a java file for TestSuite and a java file for AndroidTestCase. And now I have the AndroidTestCase, could anyone tell me how to write the TestSuite? Thank you! 回答1: From TestSuit overview A TestSuite is a Composite of Tests. It runs a collection of test cases. Here is an example

getActionBar() works fine on devices/simulator but returns null in testcases

老子叫甜甜 提交于 2019-12-13 00:55:03
问题 Application supports minSdk=14 and have ActionBar on every Activity . Application works fine since a long time and shows ActionBar on every Activity . Now I am writing Android JUnit Testcases but it gives NullPointException on line getActionBar().setDisplayHomeAsUpEnabled(true); The bottom line is getActionBar() works on devices but returns null during test cases. If I remove the line then testcases are fine. Here's how activity looks like. protected void onCreate(Bundle savedInstanceState) {

Espresso - How to click on a random RecyclerView item?

眉间皱痕 提交于 2019-12-13 00:48:32
问题 There are a few posts that show how can you click a certain fixed item in the RecyclerView with Espresso, like: How to click on an item inside a RecyclerView in Espresso Using Espresso to click view inside RecyclerView item Example: //Change the 0 with any other number, will be the position of the item clicked. onView(withId(R.id.a_main_recycler)) .perform(RecyclerViewActions .actionOnItemAtPosition(0, click())); But, what if you want to click on a random item in the RecyclerView? 回答1: Use

AndroidTest Manifest permission not detected

佐手、 提交于 2019-12-12 19:16:41
问题 I have androidTest Manifest that has this permission: <uses-permission android:name="android.permission.SET_ANIMATION_SCALE" /> However, when I run the test, this permission is not set in my devDebug build. It only works when I add it to main/AndroidManifest.xml. Full androidTest/AndroidManifest.xml, <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.test.mobile"> <uses-sdk android:minSdkVersion="15" android