45 questions
1 vote
1 answer
62 views
How to download screenshots created using androidx.test.core.graphics.writeToTestStorage
I'm in the process of changing the Screenshots created by my Android instrumentation tests androidx.test.runner.screenshot.ScreenCaptureProcessor (which worked) to the new androidx.test.core.app....
0 votes
0 answers
33 views
Espresso 3.4.0: Certificate transparency failed
When I upgrade the Espresso Accessibility from 3.3.0 to 3.4.0 and higher, I get the following error which makes the test unable to launch the app: SSLHandshakeException: Certificate transparency ...
0 votes
1 answer
122 views
In which package are androidx.test.core.app.DeviceCapture.takeScreenshot or androidx.test.espresso.screenshot.captureToBitmap located
I'm trying to update my screenshot routine used in the instrumentation tests of multiple projects using the new suggested method. Which is, of course, more complicated then the pervious version. There ...
1 vote
1 answer
462 views
gradle could not resolve androidx library in a java-library
I'm working on setting up instrumentation tests in my java library gradle project using the androidx.test library. I added the following dependency in my build.gradle file: plugins { id 'java-...
0 votes
0 answers
189 views
How to test ViewModel using AndroidX and Hilt
I am trying to test my ViewModel class. I believe that I need to use a HiltViewModelTest annotation but, Android Studio cannot find the file.. import androidx.test.ext.junit.rules.ActivityScenarioRule ...
3 votes
1 answer
1k views
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 ...
1 vote
0 answers
641 views
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.<init>(ComponentActivity.java:...
3 votes
1 answer
381 views
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 ...
0 votes
1 answer
208 views
Filtering Android Connected Tests
I have a few "connected" tests that are only relevant to run on a specific device model or on a specific brand and should be skipped on other brands/models. I may be missing something, but ...
8 votes
0 answers
1k views
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 ...
0 votes
1 answer
617 views
How to assert the activity is finished with espresso [duplicate]
I want to assert the activity is finished after clicking a button. eg: if the user clicked button with id R.id.finish, then the activity is finished. I'm trying to look up apis with ActivitySenerio ...
4 votes
0 answers
165 views
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 ...
1 vote
1 answer
2k views
Error inflating ViewBinding in test class : Binary XML file line #38: Binary XML file line #38: Error inflating class <unknown>
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 : ...
5 votes
2 answers
699 views
Saving bitmap by writeToTestStorage method
I try to make a screenshot test with Espresso: Test class ScreenshotTest { @get:Rule var nameRule = TestName() @get:Rule var mActivityTestRule = ActivityTestRule(MainActivity::class.java) @Test ...
2 votes
0 answers
931 views
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, ...