Firebase Test Lab은 Android 앱을 테스트할 수 있는 클라우드 기반 인프라를 제공하고 Android 스튜디오와 완전히 통합되므로 계측 테스트를 실행하거나 테스트 결과를 검토할 수 있습니다.
이 가이드에서는 Test Lab과 통합하고 실행할 수 있도록 Android 스튜디오에서 계측 테스트를 수정하는 방법을 설명합니다. Android 스튜디오 UI에서 Test Lab을 사용하여 테스트 매트릭스를 만들고, 계측 테스트를 실행하고, 테스트 결과를 확인하는 방법은 Firebase Test Lab으로 테스트 실행을 참조하세요.
스크린샷 캡처
Test Lab은 계측 테스트를 실행할 때 스크린샷을 캡처하는 기능을 지원합니다. 스크린샷을 캡처하는 방법은 프로젝트에 스크린샷 라이브러리 추가를 참조하세요.
Espresso Test Recorder를 사용하여 테스트 만들기
Espresso Test Recorder 도구를 사용하면 테스트 코드를 작성하지 않고 앱의 UI 테스트를 만들 수 있습니다. 기기와의 상호작용을 기록하고 어설션을 추가하여 앱의 특정 스냅샷에서 UI 요소를 확인할 수 있습니다. 그런 다음 Espresso Test Recorder가 저장된 기록을 가져와 자동으로 Espresso UI 테스트를 생성하고 Test Lab에서 이를 실행하여 앱을 테스트할 수 있습니다.
Test Lab이 제공하는 시스템 변수를 계측 테스트에 추가하면 Test Lab에서 실행하는 계측 테스트가 테스트 기기 또는 에뮬레이터에서 실행할 때와 다르게 동작할 수 있습니다.
다음 코드 예시에서는 firebase.test.lab 시스템 속성을 읽고 테스트가 Test Lab에서 실행 중이면 testLabSetting 문자열을 true로 설정합니다.
그런 다음 이 문자열 값을 사용하여 추가 구문 실행 여부를 제어할 수 있습니다.
Kotlin
valtestLabSetting=Settings.System.getString(contentResolver,"firebase.test.lab")if("true"==testLabSetting){// Do something when running in Test Lab// ...}
StringtestLabSetting=Settings.System.getString(getContentResolver(),"firebase.test.lab");if("true".equals(testLabSetting)){// Do something when running in Test Lab// ...}
Firebase Test Lab 플러그인을 통한 Gradle 관리 기기를 사용하면 프로젝트의 Gradle 파일에 있는 구성에 따라 Test Lab 기기에서 자동화된 계측 테스트를 대규모로 실행할 수 있습니다.
Gradle 관리 기기는 또한 이전 테스트 기록을 토대로 샤드 전체에 테스트를 최적으로 배포할 수 있는 스마트 샤딩을 제공합니다. 스마트 샤딩을 사용하면 샤드가 거의 동일한 시간 동안 실행되고 가능한 한 빨리 테스트 결과를 반환합니다. 스마트 샤딩을 사용하면 대규모 테스트 모음을 동시에 실행할 수 있으므로 이 기능은 CI/CD 흐름에 적합합니다.
[[["이해하기 쉬움","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-09-04(UTC)"],[],[],null,["\u003cbr /\u003e\n\nFirebase Test Lab provides cloud-based infrastructure for testing Android\napps, and features full integration with Android Studio for running\ninstrumented tests and reviewing test results.\n\nThis guide describes how to modify instrumented tests in Android Studio so you\ncan integrate and run them with Test Lab. For instructions on using\nTest Lab from the Android Studio UI to create a test matrix, run an\ninstrumented test, and view the test results, see\n[Run your tests with Firebase Test Lab](https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests.html#run-ctl).\n\nCapture screenshots\n\nTest Lab provides support for capturing screenshots when running\ninstrumented tests. To learn how to capture screenshots, see\n[Add the screenshot library to your project](/docs/test-lab/android/instrumentation-test#add-screenshot-library).\n\nCreate tests using Espresso Test Recorder\n\nThe Espresso Test Recorder tool lets you create UI tests for your app without\nwriting any test code. You can record your interactions with a device and add\nassertions to verify UI elements in particular snapshots of your app. Espresso\nTest Recorder then takes the saved recording and automatically generates a\ncorresponding Espresso UI test that you can run to test your app in Test Lab.\n\nTo learn more, see\n[Create UI Tests with Espresso Test Recorder](//developer.android.com/studio/test/espresso-test-recorder.html).\n\nModify instrumented test behavior for Test Lab\n\nTest Lab provides a system variable that you can add to your instrumented\ntests so that you can cause them to behave differently when you run them in\nTest Lab than when you run them on your own test device or emulator.\n\nThe following code example reads a system property, `firebase.test.lab`, and\nsets a string, `testLabSetting` to `true` if the test is running in Test Lab.\nThen, it uses the value of this string to control whether additional statements\nare executed: \n\nKotlin \n\n```kotlin\nval testLabSetting = Settings.System.getString(contentResolver, \"firebase.test.lab\")\nif (\"true\" == testLabSetting) {\n // Do something when running in Test Lab\n // ...\n}https://github.com/firebase/snippets-android/blob/b694d4dbd411d31be39655f47691c3e9f3529b03/test-lab/app/src/main/java/com/google/firebase/example/testlab/kotlin/MainActivity.kt#L17-L21\n```\n\nJava \n\n```java\nString testLabSetting = Settings.System.getString(getContentResolver(), \"firebase.test.lab\");\nif (\"true\".equals(testLabSetting)) {\n // Do something when running in Test Lab\n // ...\n}https://github.com/firebase/snippets-android/blob/b694d4dbd411d31be39655f47691c3e9f3529b03/test-lab/app/src/main/java/com/google/firebase/example/testlab/MainActivity.java#L26-L30\n```\n\nUse Gradle Managed Devices via the Firebase Test Lab plugin\n\nGradle Managed Devices via the Firebase Test Lab\nplugin lets you run automated instrumented tests at scale on Test Lab\ndevices, based on the configurations in your project's Gradle files.\n\nGradle Managed Devices also offer smart sharding, which lets you distribute\ntests optimally across shards based on your previous test history. With smart\nsharding, shards run for approximately the same length of time and return test\nresults as quickly as possible. Smart sharding lets you run large test suites in\nparallel, making this feature well suited for CI/CD flows.\n\nTo enable smart sharding using the [Gradle Managed Devices Test Lab plugin](https://developer.android.com/studio/test/gradle-managed-devices#gmd-ftl),\nfollow the instructions in [Optimize test runs with smart\nsharding](https://developer.android.com/studio/test/gradle-managed-devices#smart-sharding)\n."]]