앱이 성장함에 따라 앱의 기본 프로세스가 아닌 프로세스에 일부 앱 구성요소를 배치하는 것이 유용할 수 있습니다. 기본이 아닌 프로세스에서 앱 구성요소를 테스트하려면 Multiprocess Espresso의 기능을 사용하면 됩니다.
Android 8.0 (API 수준 26) 이상에서 사용 가능한 이 도구를 통해 Espresso의 동기화 보장을 계속 유지하면서 앱의 프로세스 경계를 가로지르는 앱의 UI 상호작용을 원활하게 테스트할 수 있습니다.
Multiprocess Espresso를 사용할 때 다음과 같은 버전 관리 및 범위 고려 사항을 염두에 두어야 합니다.
앱이 Android 8.0(API 레벨 26) 이상을 타겟팅해야 합니다.
이 도구는 앱 패키지 내의 프로세스에 포함하는 앱 구성요소만 테스트할 수 있습니다. 외부 프로세스는 테스트할 수 없습니다.
도구 사용
Multiprocess Espresso를 사용하여 앱 내의 프로세스를 테스트하려면 앱의 build.gradle 파일에 espresso-remote 아티팩트 참조를 추가하세요.
두 개의 AndroidJUnitRunner 인스턴스가 핸드셰이크를 실행하여 서로 간의 연결을 설정합니다. 동시에 각 AndroidJUnitRunner 인스턴스가 Espresso와 같은 등록된 모든 클라이언트를 다른 프로세스의 상응하는 각 클라이언트와 연결하므로 이러한 클라이언트가 둘 사이의 직접 통신 채널을 형성할 수 있습니다.
각 AndroidJUnitRunner 인스턴스가 새로 추가된 계측 인스턴스와 테스트 프레임워크 클라이언트를 계속 찾으며 필요에 따라 추가 통신 채널을 설정합니다.
그림 1에서는 이 프로세스의 결과를 보여줍니다.
그림 1. Multiprocess Espresso를 사용하여 여러 계측 프로세스 간 통신 설정
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-08(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-08(UTC)"],[],[],null,["# Multiprocess Espresso\n\nAs your app grows, you might find it useful to place some of your app components\nin a process other than your app's main process. To test app components in these\n*non-default processes*, you can use the functionality of Multiprocess Espresso.\nThis tool, available on Android 8.0 (API level 26) and higher, allows you to\nseamlessly test your app's UI interactions that cross your app's process\nboundaries while maintaining Espresso's synchronization guarantees.\n\nWhen using Multiprocess Espresso, keep the following versioning and scope\nconsiderations in mind:\n\n- Your app must target Android 8.0 (API level 26) or higher.\n- The tool can only test app components that you include in processes within your app's package. It cannot test external processes.\n\nUse the tool\n------------\n\nTo test a process within your app using Multiprocess Espresso, add a reference\nto the **espresso-remote** artifact in your app's `build.gradle` file:\n\napp/build.gradle \n\n### Groovy\n\n```groovy\ndependencies {\n ...\n androidTestImplementation 'androidx.test.espresso:espresso-remote:3.6.1'\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n ...\n androidTestImplementation('androidx.test.espresso:espresso-remote:3.6.1')\n}\n```\n\nYou also need to add the following to your app's `androidTest` manifest:\n\n- An `\u003cinstrumentation\u003e` element that defines the process.\n- A `\u003cmeta-data\u003e` element indicating that you want to use Multiprocess Espresso.\n\nThe following code snippet shows how to add these elements:\n\nsrc/androidTest/AndroidManifest.xml \n\n```xml\n\u003cmanifest ... package=\"androidx.test.mytestapp.tests\"\u003e\n \u003cuses-sdk android:targetSdkVersion=\"27\" android:minSdkVersion=\"14\" /\u003e\n \u003cinstrumentation\n android:name=\"androidx.test.runner.AndroidJUnitRunner\"\n android:targetPackage=\"androidx.test.mytestapp\"\n android:targetProcesses=\"*\"\u003e\n \u003cmeta-data\n android:name=\"remoteMethod\"\n android:value=\"androidx.test.espresso.remote.EspressoRemote#remoteInit\" /\u003e\n \u003c/instrumentation\u003e\n\u003c/manifest\u003e\n```\n\nThe previous snippet indicates to the Android framework that you want it to test\nevery process in your app's package. If you want to test only a subset of your\napp's processes, you can specify a comma-separated list within the\n[targetProcesses](/reference/android/content/pm/InstrumentationInfo#targetProcesses) element instead: \n\n \u003cinstrumentation\n ...\n android:targetProcesses=\n \"androidx.test.mytestapp:myFirstAppProcessToTest,\n androidx.test.mytestapp:mySecondAppProcessToTest\" ... /\u003e\n\n| **Note:** Multiprocess Espresso ignores the value of [targetProcesses](/reference/android/content/pm/InstrumentationInfo#targetProcesses) if you set it to your app package's main process.\n\nUnderstand the tool's architecture\n----------------------------------\n\nWhen you test your app and launch its default process, you might perform a UI\ninteraction, such as a button press, that starts an activity in a secondary\nprocess. The system then completes the following steps to enable cross-process\ntesting using Espresso:\n\n1. The Android Framework creates and starts a new process to follow your app's navigational structure. Each [Instrumentation](/reference/android/app/Instrumentation) process includes a new instance of [`AndroidJUnitRunner`](/reference/androidx/test/runner/AndroidJUnitRunner). At this stage, the 2 instrumentation processes cannot communicate with each other.\n2. Each [`AndroidJUnitRunner`](/reference/androidx/test/runner/AndroidJUnitRunner) instance registers Espresso as its testing framework.\n3. The 2 instances of [`AndroidJUnitRunner`](/reference/androidx/test/runner/AndroidJUnitRunner) perform a handshake to establish a connection between each other. At the same time, each [`AndroidJUnitRunner`](/reference/androidx/test/runner/AndroidJUnitRunner) instance connects all registered clients like Espresso with their respective counterparts in other processes so that these clients can form a direct communication channel between themselves.\n4. Each [`AndroidJUnitRunner`](/reference/androidx/test/runner/AndroidJUnitRunner) instance continues to look for newly-added instrumentation instances and testing framework clients, establishing additional communication channels as needed.\n\nFigure 1 illustrates the result of this process:\n**Figure 1.** Establishing communication between multiple instrumentation processes using Multiprocess Espresso\n\nAdditional resources\n--------------------\n\nFor further information on this topic, consult the following resources.\n\n- [Test-Driven Development on Android with the Android Testing Support\n Library](https://www.youtube.com/watch?v=pK7W5npkhho&start=2201) session video from Google I/O 2017, beginning at 36:41."]]