android-junit

How do I unit test (with JUnit or mockito) recyclerview item clicks

冷暖自知 提交于 2019-12-20 18:10:13
问题 I am currently trying to unit test recyclerview addonitemclick listner, with either junit or mockito. here's my code: private void mypicadapter(TreeMap<Integer, List<Photos>> photosMap) { List<PhotoListItem> mItems = new ArrayList<>(); for (Integer albumId : photosMap.keySet()) { ListHeader header = new ListHeader(); header.setAlbumId(albumId); mItems.add(header); for (Photos photo : photosMap.get(albumId)) { mItems.add(photo); } pAdapter = new PhotoViewerListAdapter(MainActivity.this, mItems

Test text submit on SearchView when using Espresso

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 03:22:52
问题 How can I submit some text to SearchView in androidTest ? onView(withId(R.id.search_src_text)).perform(typeText("text")) doesn't work for me - app crashes at this line @Test fun testSearchViewTextSubmit() { ActivityScenario.launch(MainActivity::class.java) onView(withId(R.id.search_action)).perform(click()) // ok onView(withId(R.id.search_src_text)).perform(typeText("text")) // failed } androidx.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: com.example

Android instrumented unit testing Cannot resolve symbol 'AndroidJUnit4'

不打扰是莪最后的温柔 提交于 2019-12-12 11:48:51
问题 I trying to add Android Support Instrumentation test to my application, but i run this problem: Cannot resolve symbol 'AndroidJUnit4' Its seems i don't have the package android.support.test.runner my app's build.gradle: apply plugin: 'com.android.application' apply plugin: 'realm-android' android { compileSdkVersion 23 buildToolsVersion "23.0.2" defaultConfig { applicationId "---PACKAGENAME---" minSdkVersion 15 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner

AndroidJUnit4 test not found

人盡茶涼 提交于 2019-12-10 09:52:17
问题 I annotated my class like here @RunWith(AndroidJUnit4.class) public class WorkdayProviderTest Futhermore, annotated also my test method like this @Test public void insert_dataInsertsCorrectly() Finally, configured my build.gradle defaultConfig and dependencies like this defaultConfig { applicationId 'com.jueggs.workinghours' minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } androidTestCompile

Unable to find instrumentation info for: ComponentInfo{../android.support.test.runner.AndroidJUnitRunner}

筅森魡賤 提交于 2019-12-08 01:32:57
问题 I have written a simple Android instrumental test case to test networking operation. Test case class name: Main3ActivityTest.java Method name:addNewEmployee I run my test case using command line then I got following exception. Command: ./adb -s emulator-5554 shell am instrument -w -r -e class murali.myapplication.Main3ActivityTest#addNewEmployee murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner Issue: INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION

Android RecyclerView Adapter is giving null on unit testing

[亡魂溺海] 提交于 2019-12-07 03:09:02
问题 I am trying to test RecyclerView with AndroidJunit4, it is my test code: package com.kaushik.myredmart.ui; // all includes @RunWith(AndroidJUnit4.class) public class ProductListActivityTest { @Rule public ActivityTestRule<ProductListActivity> rule = new ActivityTestRule<>(ProductListActivity.class); @Test public void ensureListViewIsPresent() throws Exception { ProductListActivity activity = rule.getActivity(); View viewByIdw = activity.findViewById(R.id.productListView); assertThat(viewByIdw

Unable to find instrumentation info for: ComponentInfo{../android.support.test.runner.AndroidJUnitRunner}

こ雲淡風輕ζ 提交于 2019-12-06 13:05:07
I have written a simple Android instrumental test case to test networking operation. Test case class name: Main3ActivityTest.java Method name:addNewEmployee I run my test case using command line then I got following exception. Command: ./adb -s emulator-5554 shell am instrument -w -r -e class murali.myapplication.Main3ActivityTest#addNewEmployee murali.myapplication.test/android.support.test.runner.AndroidJUnitRunner Issue: INSTRUMENTATION_STATUS: id=ActivityManagerService INSTRUMENTATION_STATUS: Error=Unable to find instrumentation info for: ComponentInfo{murali.myapplication.test/android

AndroidJUnit4 test not found

孤街浪徒 提交于 2019-12-05 18:36:03
I annotated my class like here @RunWith(AndroidJUnit4.class) public class WorkdayProviderTest Futhermore, annotated also my test method like this @Test public void insert_dataInsertsCorrectly() Finally, configured my build.gradle defaultConfig and dependencies like this defaultConfig { applicationId 'com.jueggs.workinghours' minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } androidTestCompile "junit:junit:4.12" androidTestCompile "com.android.support:support-annotations:23.3.0" androidTestCompile