Questions tagged [androidx-test]
41 questions
20
votes
3 answers
Android Test Orchestrator not working with Android X
I have recently migrated my project to use AndroidX, and have configured test orchestrator for my espresso tests on gradle using the following docs:
https://developer.android.com/training/testing/junit-runner#using-android-test-orchestrator
I have…

FlashAsh80
- 1,357
- 1
- 16
- 27
15
votes
1 answer
Robolectric AndroidX fragments NoClassDefFoundError
After migration of code and tests to AndroidX, all seems to work pretty well, however Robolectric junit tests for two fragments are failing due to NoClassDefFoundError: androidx/fragment/testing/R$style exception.
The stack…

Marcin Bak
- 1,410
- 14
- 25
8
votes
1 answer
Jetpack AndroidX Test "Write Once, Run Everywhere" - But What is the best way to run Everywhere?
Recently I show one of the google IO video about androidX testing which quote "Write Once, Run EveryWhere". Which makes me exciting to learn about androidX testing library.
And what I found that After long time google come up with the nice single…

Moinkhan
- 12,732
- 5
- 48
- 65
6
votes
4 answers
No tests found when using custom runner
I'm using androidx.test libraries(which I migrated to recently) in my project and using custom AndroidJUnitRunner.
Before migration it was all working fine but now I'm getting this error -
Started running tests
Test running failed: Instrumentation…

Shadab Ansari
- 7,022
- 2
- 27
- 45
5
votes
1 answer
AndroidTests stopped building after adding androidx.fragment:fragment-testing dependency
After I have added fragment-testing dependency to my project:
// Testing dependencies
espressoVersion = '3.2.0-beta01'
testCoreVersion = '1.1.0'
runnerVersion = '1.1.0'
extJunitVersion = '1.1.0'
testRulesVersion = '1.1.0'
…

amp
- 11,754
- 18
- 77
- 133
5
votes
1 answer
How to configure Android project for AndroidX Test
I am having difficulty configuring my Android application for testing with AndroidX.
When I attempt to run my initial test I get this error:-
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task…

Hector
- 4,016
- 21
- 112
- 211
5
votes
0 answers
How to test options menu using AndroidX fragment test?
Setup
Robolectric: 4.2.1
AndroidX fragment-testing: 1.1.0-alpha05
Background
With AndroidX comes new ways of testing fragments:
Source:
https://developer.android.com/training/basics/fragments/testing
Robolectric is compatible with AndroidX and…

Alix
- 2,630
- 30
- 72
4
votes
0 answers
How to construct unit tests combining Robolectric and AndroidX with Jetpack Compose?
Assumptions
Robolectric controls which Android version to emulate, so I need this
AndroidX has the test API for Jetpack Compose, so I need this as well
Background
I have experienced a lot of AppNotIdleException when running the full test suite,…

Alix
- 2,630
- 30
- 72
4
votes
0 answers
What is the new preferred approach to running code before and after activity finishes with ActivityScenarioRule?
Previously with ActivityTestRule, one was able to override beforeActivityLaunched and afterActivityFinished to control app state before and after all tests (e.g, implementing a custom rule Class that extended ActivityTestRule that would be used in…

AaronMT
- 1,605
- 2
- 11
- 6
4
votes
1 answer
FragmentScenario of DialogFragment, onCreateDialog not called
I want to test DialogFragment using androidx.fragment:fragment-testing lib.
I call launchFragmentInContainer and moveToState(Lifecycle.State.RESUMED), but onCreateDialog is not called in this fragment.
@Test
fun `submit search - presenter…

Oleksandr Albul
- 1,611
- 1
- 23
- 31
4
votes
1 answer
java.lang.NoClassDefFoundError: Test Module could not resolve classes of other Feature Module, Unit Testing - Kotlin - Android
I have the following Project Structure:
Main App
--app
--featureModule1
--featureModule2
--TestKit(Library module)
where Testkit has all dependencies including app and featureModules. The Testkit included all the unit tests related to the…

Amritpal Singh
- 984
- 2
- 14
- 33
4
votes
0 answers
AndroidX Test - ActivityScenario onView() can't find nested child fragment
I have an activity MyActivity which in turn holds a fragment MyFragment. In MyFragment I show a BottomSheetDialogFragment using the childFragmentManager as below:
bottomSheetFragment.show(childFragmentManager, "BottomSheetFragment")
The below is my…

Henry
- 17,490
- 7
- 63
- 98
4
votes
0 answers
Testing BottomSheetDialog item click() with Robolectric and androidx.testing
I'm trying to test a BottomSheetDialog using androidx.test and Robolectric and hitting a problem with trying to click a button in the dialog.
onView(withId(R.id.fab_add)).perform(click())
onView(withId(R.id.button_add_activity))
…

Ben Neill
- 2,811
- 2
- 22
- 20
3
votes
1 answer
After cleaning gradle, androidx-test.core module throws merged-manifest errors
In a react-native project, ive recently updated to v66.4 from v63.2
after some dependency conflict troubleshooting, i ultimately get a merged manifest error, that indicates suggestions for 3 locations
initially this was 4 locations
i added…

Jim
- 1,988
- 6
- 34
- 68
3
votes
0 answers
Why is the main activity not maintained throughout the entire test?
So I'm having some issues with the login of an app.
I've been trying to write an integration test for it...
class LoginIT : AndroidIntegrationTest() {
@get:Rule
var loginActivityRule = activityScenarioRule()
var done =…

User1291
- 7,664
- 8
- 51
- 108