Questions tagged [instrumented-test]

Framework for Android instrumented testing to interact with UI components.

116 questions
38
votes
5 answers

Fragment Not Associated With A Fragment Manager

I am writing some instrumented tests for an app with one activity and multiple fragments using the Navigation Component. The code for my splash screen is as below: class SplashFragment : Fragment(), KodeinAware { override val kodein by…
12
votes
2 answers

Android studio Instrumented Test stuck at: Task :app:connectedDebugAndroidTest

I have encountered a problem that when I tried to run Android Instrument test, android studio will start building, everything is good until it stuck to this line "> Task :app:connectedDebugAndroidTest" and run for the next 2hrs and never proceed the…
6
votes
2 answers

com.android.tools.r8.internal.Jc: Space characters in SimpleName exception are not allowed prior to DEX version 040

I'm trying to using backticks ` in the definition of my instrumented tests. I don't understand why compiler complains about a strange error: Caused by: com.android.tools.r8.internal.Jj: com.android.tools.r8.internal.Jc: Space characters in…
6
votes
1 answer

Merged test apk for dynamic feature modules

Is there a way to create a universal APK for instrumented tests? I wanted to run the whole test suite on Firebase Test Lab but it seems tedious to upload one APK for each dynamic feature module's test APK. For the app, you can do a…
6
votes
0 answers

Android test orchestrator no tests were found

I am developing an Android application using Kotlin programming language. I am writing instrumented tests for my application. I am also using the test orchestrator to run my instrumented tests. But after the installation of the test orchestrator…
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
5
votes
1 answer

new MockWebServer fails with java.lang.NoClassDefFoundError ( TaskRunner$RealBackend )

I am trying to use okhttp3.mockwebserver.MockWebServer for some intrumented testing on Android. This is what I have in my build.gradle (:app) file for instrumented testing: androidTestImplementation 'androidx.annotation:annotation:1.1.0' …
Nick
  • 1,118
  • 9
  • 14
5
votes
0 answers

Android instrumented test throws exception: Activity never becomes requested state "[RESUMED, DESTROYED, STARTED, CREATED]"

This is the shortest variant of the test: … @RunWith(AndroidJUnit4.class) @LargeTest public class RunAllTest { @Test public void testShortRun() { Context ctx = ApplicationProvider.getApplicationContext(); Intent intent = new Intent(ctx,…
Ivan
  • 51
  • 2
4
votes
1 answer

How to test rememberSaveable with Rotation Change in Jetpack Compose

I am using Android Studio Arctic fox and I try to test the behaviour of a variable that is stored using rememberSaveable. I did the test manualy by doing "Rotate Left" in Emulator. There the behaviour is as expected : value stored using remember is…
4
votes
1 answer

FragmentScenario must implement OnFragmentInteractionListener

I am currently trying to test the navigation in android with androidTest, mokito and espresso like suggested in this tutorial: https://developer.android.com/guide/navigation/navigation-testing But I systematically get the following…
Cunningham
  • 178
  • 2
  • 10
4
votes
0 answers

Android instrumented test manually granting the permissions in the beginning of each test method using GrantPermissionRule

I am developing an Android app using Kotlin. I am writing instrumented tests for my application. I am granting the permissions in my test using GrantPermissionRule as below. @get:Rule var permissionRule: GrantPermissionRule =…
Wai Yan Hein
  • 13,651
  • 35
  • 180
  • 372
4
votes
0 answers

Is there a workaround to mock the injected view model of a second activity opened during an instrumented test in Android?

I am writing an instrumented test for an activity using ActivityTestRule which will open a second activity by pressing a button on the under test (first) activity. The problem is, the second activity uses dependency injection to inject a viewmodel…
superus8r
  • 751
  • 1
  • 11
  • 24
3
votes
3 answers

How to iterate over an element (node) list on Android Jetpack Compose UI Tests?

I'm implementing some instrumented tests using the Jetpack Compose testing library. I'm not too familiar with Kotlin / Android development yet, but I have years of experience with Selenium and other testing libraries, so I'm missing some basic…
3
votes
2 answers

How to assert next started activity for a composable test?

I have a composable with a button that launches one of the native activities (Google Settings). To test this before compose (using Robolectric) I would do something like this: My test: @Test fun `MyFragment - when button clicked - starts activity`()…
3
votes
1 answer

How to test Alarm Manager using Unit Test or Instrumented Test in Android

I am facing an issue to test the alarms that set on alarm manager. I want to check the alarm manager using unit test or Instrumented test. val alarmManager1 = context.getSystemService(Context.ALARM_SERVICE) as AlarmManager val alarmIntent1 =…
3
votes
0 answers

Can you set an Android emulator to Night mode during instrumented test?

I'm writing instrumented android tests that take screenshots for the app's Play Store listing. I would like to be able to toggle night mode on the emulator, so I can get screen caps of the activity using both themes. Is there any way to set an…
Bob Liberatore
  • 860
  • 10
  • 24
1
2 3 4 5 6 7 8