android-testing

Can't run android test suite: Exception in thread “main” java.lang.ClassNotFoundException

若如初见. 提交于 2019-12-11 23:19:12
问题 I have 2 test classes that I need to run on a test suite one is RestaurantModelTest the other is CartModelTest.class : @Config(sdk = 16, manifest = "src/main/AndroidManifest.xml") @RunWith(RobolectricTestRunner.class) public class RestaurantModelTest { //setUp code here... @Test public void testFindByLocation() throws Exception { //test code here } } So I followed some tutorials online and they specify to create a TestSuite class like this with my 2 classes to be tested: import org.junit

How to write script in python to reboot android tablet multiple times

别说谁变了你拦得住时间么 提交于 2019-12-11 17:34:02
问题 How can I write script in python to reboot android tablet and launch any app multiple times. Is there any better way to automate this test. 回答1: you can use the command adb reboot to reboot a device. There are likely a plethora of ways you could use python to make this adb command. The simplest of which that I can think of is: import os os.system("adb reboot") you'll have to either put a path infront of adb, run this from the folder that adb is in, or add the folder that adb is in to your

How to catch exceptions using ActivityInstrumentationTestCase2?

我是研究僧i 提交于 2019-12-11 11:16:22
问题 I'm struggling to catch expected exceptions in test cases of my Android app using the class ActivityInstrumentationTestCase2. I wrote a very simple scenario that is raising the issue, and once this is solved I can probably do the same thing for my app. The snippet of the simple scenario is below. First, there is the application that I want to test, which raises a NullPointerException in its onCreate method. package com.example.crashtest; import android.app.Activity; import android.os.Bundle;

Espresso idling resource not working if long running task is started in Activity's onCreate?

人盡茶涼 提交于 2019-12-11 08:57:06
问题 How to use espresso idling resource if long running task is started in Activity's onCreate ? I have created a custom IdlingResource and it is working fine if the long async method call is triggered by click event, but breaks whenever the it is called in Acitivty's onCreate method. Example: public void onBtnClick(){ setIdle(true); // This works fine, our tests wait until setIdle(false) is called doSomeBackgroundTask(); } public void onDone(){ setResourceIdle(false); setIdle(false); } @Override

How can I swap test doubles at the scope of an Activity or a Fragment using Dagger 2?

岁酱吖の 提交于 2019-12-11 06:45:26
问题 EDIT: Watch out! I have deleted the old repository reffered to in this question. See my own answer to the question for a possible solution and feel free to improve it! I am refering to my post here. Now I came a little further. I am also refering to my two branches within my github Project: Experimental [branch no. 1] (repository deleted) Experimental [branch no. 2] (repository deleted) In the old post I tried to swap components to test-components within an Instrumentation Test. This works

Androidx ServiceTestRule cannot find my service

烂漫一生 提交于 2019-12-11 05:39:31
问题 To be fair, I am not testing the service, but am using a service as part of my test classes to test a Bluetooth library. So my test class needs to create a service that invokes the Bluetooth library. The test class then needs to bind to this service to perform the tests. However, attempting to start the service always gives me the following error which leads to a Nullpointer exception W/ActivityManager: Unable to start service Intent { cmp=com.example.androidhdpadapter.test/com

Test that app launches another app in Android

我们两清 提交于 2019-12-11 04:55:17
问题 I have a very simple activity, that redirects the user to the app's Play Store page, when the button is clicked: public class MyActivity extends AppCompatActivity { private static final String PLAY_STORE_URI = "market://details?id=" + BuildConfig.APPLICATION_ID; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.my_activity); findViewById(R.id.go_to_play_store).setOnClickListener(this::goToPlayStore); } public

testing with mock in robotium

那年仲夏 提交于 2019-12-11 03:40:19
问题 i am using mock for my test in Rbotium. My first test fail and another test pass. i think it is because of that the mock is not ready for the test. but when i add a fake test all of my tests passes. my fake test: public void test_ShowA_HomeActionbarTabClicked() { assertEquals("",""); } all tests: public void test_ShowCategoryGamesListFragment_CategoryListActionbarTabClicked() { //click on Categories action bar tab getSolo().clickOnText(getSolo().getCurrentActivity().getString(R.string.title

Android: Runtime error while UiTesting

£可爱£侵袭症+ 提交于 2019-12-11 00:00:07
问题 I am trying to run a Ui test, and everytime I run the applicatoin it gives the following error in the console and closes the app that is running. I have the uiautomator.jar, android.jar & JUnit4 libraries imported. Im using Eclipse. What am I missing here? [2016-04-04 04:44:00 - UiTests] Test run failed: Instrumentation run failed due to 'java.lang.RuntimeException' TestClass package android.support.v7.appcompat.test; import com.android.uiautomator.core.UiObject; import com.android

How can we automatically only run tests on newer Android versions?

微笑、不失礼 提交于 2019-12-10 22:24:55
问题 I discovered that one test, in particular, fails consistently on pre-KitKat devices. I believe it's related to the change in embedded WebView used on older Android devices (but perhaps this is mistaken). Anyway, back to my question: I'd like an elegant way to control whether a test is run depending on the version of Android that's running on the device. Currently, I use code that short-circuits the test and passes it if the runtime is earlier than KitKat. Here's the relevant code: if (Build