Questions tagged [androidx-test]

41 questions
3
votes
1 answer

How to keep tests that test recovery of activities from a bundle in single test suite with other tests using launchActivity

I have a test suite for an android application, testing multiple scenarios. For most of them it makes sense to use AndroidX test framework's launchActivity. I also have, in the same suite, tests that tests the recovery of activities from a bundle.…
JE42
  • 4,881
  • 6
  • 41
  • 51
2
votes
0 answers

Android UI testing - ActivityScenarioRule is significantly slower then ActivityScenario

I'm getting into Android UI testing, and I learnt two ways to start up activities: ActivityScenario in each test, and ActivityScenarioRule once, annotated with @Rule. At first I used ActivityScenario, with success. Each test took around 2-4 second…
2
votes
1 answer

Android Issue::More than one file was found with OS independent path 'androidsupportmultidexversion.txt' "error"

I am getting this issue while compiling my project I have tried a few solutions for that and that is More than one file was found with OS independent path 'META-INF/LICENSE' On gradle:3.0.0 More than one file was found with OS independent path…
2
votes
1 answer

I am confused when to use instrumentation test and when to use unit test

With AndroidX Test Framework now we can run Espresso test as unit test using Robolectric backend . But am confused when to use instrumentation test and when to use unit test. Let's say we've two screens, MovieListActivity and MovieDetailActivity.…
theapache64
  • 10,926
  • 9
  • 65
  • 108
2
votes
0 answers

GrandPermissionRule doesn't work after extending AndroidJUnitRunner

After extending AndroidJUnitRunner GrandPermissionRule stopped working and the test is blocked by permission dialog. Here is my runner class: package com.my.package import android.app.Application import android.content.Context import…
2
votes
1 answer

In which AndroidX library is the androidx.test.annotation package located?

Simple question: How can I use the androidx.test.annotation package? In which AndroidX library is it located? I'm specifically looking to use androidx.test.annotation.UiThreadTest. This annotation is the continuation of…
1
vote
1 answer

runTest does not run on main thread

I am writing a test and I get this error from a standard library: java.lang.IllegalStateException: Method addObserver must be called on the main thread This is my simplified test method: @Test fun useAppContext() = runTest { …
1
vote
0 answers

java.lang.NoClassDefFoundError: android/window/OnBackInvokedCallback for ComponentActivity

Running Jacoco results in following error message: java.lang.NoClassDefFoundError: android/window/OnBackInvokedCallback at androidx.activity.ComponentActivity.(ComponentActivity.java:150) at…
Ralf Wickum
  • 2,850
  • 9
  • 55
  • 103
1
vote
1 answer

Error inflating ViewBinding in test class : Binary XML file line #38: Binary XML file line #38: Error inflating class

I am trying to write unit tests for a RecyclerView.ViewHolder class which uses ViewBinding but I am facing issues to inflate my ViewBinding in my test class, having this error when running my test : Binary XML file line #38: Binary XML file line…
Alan
  • 1,264
  • 1
  • 11
  • 21
1
vote
0 answers

Android Unit Test problem : No instrumentation registered! Must run under a registering instrumentation

I followed Android Developer doc and try to make a simple unit test in a Android Project. But I try to run the unit test with ApplicationProvider.getApplicationContext() than I got a exception: java.lang.IllegalStateException: No…
Jast Lai
  • 21
  • 3
1
vote
0 answers

Cannot resolve symbol ‘ActivityTestRule’ on androidx

I'm trying to test my Activity, but couldn't able to import ActivityTestRule. My gradle file apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' // Add the Firebase Crashlytics plugin. apply plugin:…
Manikandan
  • 1,479
  • 6
  • 48
  • 89
1
vote
1 answer

Dagger2 + ActivityInjection + AndroidXTest/Espresso/RoboElectric in library project

I am working on android library module and I want to test the standalone activity in my module. I was following the article https://medium.com/androiddevelopers/write-once-run-everywhere-tests-on-android-88adb2ba20c5 to use roboelectric and androidx…
1
vote
1 answer

How do I import ActivityScenario?

I am attempting to follow the Android ActivityScenario documentation to write Robolectric-based tests. Adding androidTestImplementation "androidx.test.core:app:1.2.0" to my build.gradle allows me to add import…
Hélène Martin
  • 1,409
  • 2
  • 15
  • 42
1
vote
0 answers

Android Studio 3.5.2 androidx test became an unresolved reference

This morning, my android studio updated automatically. And UI testing with espresso is broken. The android jetpack test module became an unresolved reference now. Do you have any solution for it? 13:11 Executing tasks:…
hyung jun yoo
  • 613
  • 6
  • 15
1
vote
1 answer

Robolectric Cannot invoke setValue on a background thread

I am testing an AsyncTask that onPostExecute calls setValue of a LiveData instance. Since I am invoking setValue from onPostExecute no issues were expected regarding the invocation being done by the UI thread. Yet running this in a Robolectric unit…