android-instrumentation

Testing RxJava2 using Espresso and getting a null pointer exception when suscribeOn

时间秒杀一切 提交于 2019-12-23 07:24:50
问题 Android Studio 3.0 Beta2 I am testing getting a list for an endpoint using RxJava2. The app works fine when running normally. However, when I test using espresso I get a null pointer exception when I try and subscribeOn(scheduler) . For the schedulers I use the trampoline() for both subscribeOn and observeOn which are injected. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'io.reactivex.Observable io.reactivex.Observable.subscribeOn(io.reactivex.Scheduler)' on a

Getting Instrumentation run failed due to 'java.lang.NullPointerException'

£可爱£侵袭症+ 提交于 2019-12-23 07:08:28
问题 I am trying to write Unit test cases for Activities in my app by extending the test class with ActivityUnitTestCase . I could successfully run the test cases earlier but now I'm always getting the exception while running them. Even though I'm pretty familiar with handling NullPointerExceptions , I couldn't figure out the problem that's causing this. I couldn't find any similar questions so I'm posting this one. Stack trace shows me there is a null object reference at this line in my code

Running instrumentation tests from specific package via spoon-gradle plugin

家住魔仙堡 提交于 2019-12-22 09:14:31
问题 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

How to implement MockWebServer to work with proxy

半腔热情 提交于 2019-12-22 00:25:43
问题 I am trying to implement a MockWebServer from Square and i am behind a proxy. The problem is that every time i am executing my instrumentation test will fail because i am getting a 407 for every request i am doing to my MockWebServer. debug.level.titleD/OkHttp: <-- 407 Proxy Authentication Required http://localhost:12345/user/login (767ms) As u see i am pointing to my localhost and i dont know why i am getting this! Here is my MockWebServer implementation! public class MockedTestServer {

JaCoCo + Mockito + Android tests: Zero coverage reported

十年热恋 提交于 2019-12-21 21:05:25
问题 I know there are quite a few questions (and answers) for this topic, but I've tried everything I found in SO and other sites and I haven't found a way to make JaCoCo include coverage for Android tests that use Mockito. My problem: I want to use JaCoCo to generate code coverage of both Unit Test and Instrumentation Test (androidTest). I'm using Mockito to mock some of the classes. I found a sample in GitHub to use JaCoCo and used it as a starting point. https://github.com/rafaeltoledo/unified

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

烈酒焚心 提交于 2019-12-21 07:41:06
问题 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

android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED

随声附和 提交于 2019-12-21 06:10:00
问题 I'm trying to write test cases for my activities. I have several activities and there is no issue for one of them while I'm getting following error when I try to run tests over other ActivityTest classes. android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)? This is my class that all my test cases fails: @RunWith(AndroidJUnit4.class) @LargeTest public class LocatingActivityTest { @Rule

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

自作多情 提交于 2019-12-19 09:57:45
问题 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

How to regain Access on a Activity after sending it to background

蹲街弑〆低调 提交于 2019-12-13 12:29:31
问题 With Espresso I try to test sending an Activity to background, with the Home button and then getting it up in the foreground again to make some checks: @EspressoTest public void test() { onSomeView().check(matches(isDisplayed())); getInstrumentation().sendKeyDownUpSync(KeyEvent.KEYCODE_HOME); Context context = getInstrumentation().getTargetContext(); Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);

Engagement Time Calculation When App Is In Background

久未见 提交于 2019-12-13 04:18:15
问题 How to calculate engagement time whenever my app is in background. User engagement (firebase automatically collected event) calculate periodically, while the app is in the foreground. But how to add the time in user engagement when my app is in back ground. Or i need to instrument other event.. Any Idea???? 回答1: When your app is in the background, the user isn't "engaged" with it at all. With newer versions of Android, the OS may immediately kill your backgrounded app at any time without