robotium

How to expect an exception in Robotium?

扶醉桌前 提交于 2019-12-20 03:53:12
问题 Here is my test case: public void testStartActivityWithoutExtraData() { try { getActivity(); Assert.fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { assertTrue(true); } } The Activity under a test throws an Exception if it is started without extras . So in this test I expect for an IllegalStateException , but test always fails because of the issue: Test failed to run to completion. Reason: 'Instrumentation run failed due to 'java.lang

I can run Robotium test but cannot debug it

折月煮酒 提交于 2019-12-20 03:43:21
问题 I'm testing an apk for which I don't have sources on my phone. I have ensured that I have the same certificates in both the test and app apks. I'm able to run my tests fine from eclipse, but when I try to debug through "Debug As", eclipse appears to be stuck launching the tests. In the progress bar at the bottom, I see "Launching: Creating source locator...". I have set breakpoints in the appropriate spots, and nothing that I can see in the logcat output to suggest that there's a crash in

how to create a robotium testsuite?

雨燕双飞 提交于 2019-12-20 02:15:25
问题 with the code below, the tests are not executed in the order I'd like. test_homescreen is executed before test_splashscreen. I'd like to specify the tests to run and their order of execution. I believe I need to create a testsuite, but I don't know how to implement that. package com.myapp.test; import com.jayway.android.robotium.solo.Solo; import android.test.ActivityInstrumentationTestCase2; import com.myapp.R; public class myTest extends ActivityInstrumentationTestCase2{ private static

Android Robotium - How to manage the execution order of testcases?

喜你入骨 提交于 2019-12-19 20:00:11
问题 I am trying to use Robotium to automate the testing of an application. The test cases were documented and they are supposed to be test in specific order. But it seems that Junit run the tests in alphabetic order.. how do I rearrange the order of execution? Here is the basic structure of my test class: public class ETTerminalTest extends ActivityInstrumentationTestCase2<IdleActivity> { private Solo solo; private static final Logger LOGGER = LoggerFactory.getLogger(ETTerminalTest.class); public

Android Robotium - How to manage the execution order of testcases?

元气小坏坏 提交于 2019-12-19 20:00:07
问题 I am trying to use Robotium to automate the testing of an application. The test cases were documented and they are supposed to be test in specific order. But it seems that Junit run the tests in alphabetic order.. how do I rearrange the order of execution? Here is the basic structure of my test class: public class ETTerminalTest extends ActivityInstrumentationTestCase2<IdleActivity> { private Solo solo; private static final Logger LOGGER = LoggerFactory.getLogger(ETTerminalTest.class); public

Test run failed: Test run failed to complete. Expected 1 tests, received 0

徘徊边缘 提交于 2019-12-19 05:22:08
问题 I tried starting a JUnit test (robotium) for my app: public class MainTest extends ActivityInstrumentationTestCase2<MainActivity> { private Solo solo; public MainTest() { super("nix.android.contact", MainActivity.class);// TODO Auto-generated constructor stub } protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(), getActivity()); } public void AddContact() { solo.assertCurrentActivity("main", MainActivity.class); } } Manifest <instrumentation android

Android test raw resource

 ̄綄美尐妖づ 提交于 2019-12-18 13:53:10
问题 I have the following folder structure in Android Studio: ├── androidTest │ ├── java │ └── res │ └── raw │ └── test_file └── main ├── java └── res └── raw └── app_file I'm trying to access the test_file resource which exists in the raw folder of the androidTest elements. Here's the code inside a Robotium test case that inherits from ActivityInstrumentationTestCase2 : InputStream is = this.getInstrumentation() .getContext() .getResources() .openRawResource(R.raw.test_file); Android Studio

How to start Instrumentation project programmatically using Android Intent?

纵饮孤独 提交于 2019-12-18 13:32:29
问题 one way to start testcase is, adb shell am instrument -w com.google.vishal.test/android.test.InstrumentationTestRunner i want to start this using Android code (with intent) for example, adb shell am start -n com.google.android.contacts/.ContactsActivity we can run using Android intent by following method :- Intent intent = new Intent(com.google.android.contacts, ContactsActivity.class); startActivity(intent); But, how to run adb shell am instrument -w com.google.vishal.test/android.test

How can I run a single test with gradle android

人走茶凉 提交于 2019-12-18 11:17:45
问题 I'm trying to run the tests with this line... but this launches all tests: ./gradlew -DconnectedAndroidTest.single=LandingActivityTests connectedAndroidTest How can I launch a single test? 回答1: you can run the single android test in two steps: ./gradlew installDebugAndroidTest adb shell am instrument -w -e class com.example.MyInstrumentationTest#testFoo com.example.test/android.support.test.runner.AndroidJUnitRunner https://developer.android.com/tools/testing/testing_otheride.html 回答2: Since

Click all the list view elements while scrolling using robotium

馋奶兔 提交于 2019-12-18 04:29:12
问题 I have a listView that contains lots of elements i.e. we have to scroll down to see all the elements. Now what i want to do is, click all the listView elements. How can I do that. Right now,I am using the following code but it doesn't scroll automatically. Please help. ListView l = solo.getCurrentListViews().get(0); assertNotNull("No list views!", l); assertTrue("No items in list view!", l.getChildCount() > 0); // Get the last list item View v = l.getChildAt(l.getChildCount()); System.out