با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
Firebase Test Lab زیرساختهای مبتنی بر ابر را برای آزمایش برنامههای Android ارائه میکند و دارای یکپارچگی کامل با Android Studio برای اجرای تستهای ابزاردار و بررسی نتایج آزمایش است.
این راهنما نحوه تغییر تستهای ابزاردار را در Android Studio توضیح میدهد تا بتوانید آنها را با Test Lab ادغام و اجرا کنید. برای دستورالعملهای مربوط به استفاده از Test Lab از رابط کاربری Android Studio برای ایجاد یک ماتریس تست، اجرای یک تست ابزاری و مشاهده نتایج آزمایش، به اجرای آزمایشهای خود با Firebase Test Lab مراجعه کنید.
تست ها را با استفاده از ضبط کننده تست اسپرسو ایجاد کنید
ابزار Espresso Test Recorder به شما امکان میدهد بدون نوشتن کد تست، تستهای رابط کاربری را برای برنامه خود ایجاد کنید. میتوانید تعاملات خود را با یک دستگاه ضبط کنید و برای تأیید عناصر رابط کاربری در عکسهای فوری خاص برنامهتان، ادعاهایی اضافه کنید. ضبط کننده تست اسپرسو سپس ضبط ذخیره شده را می گیرد و به طور خودکار یک تست رابط کاربری اسپرسو مربوطه ایجاد می کند که می توانید برای آزمایش برنامه خود در 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// ...}
از دستگاه های مدیریت شده Gradle از طریق افزونه Firebase Test Lab استفاده کنید
دستگاههای مدیریتشده Gradle از طریق افزونه Firebase Test Lab به شما امکان میدهد بر اساس پیکربندیهای موجود در فایلهای Gradle پروژه، آزمایشهای خودکار خودکار را در مقیاس دستگاههای Test Lab اجرا کنید.
دستگاههای مدیریتشده Gradle نیز اشتراکگذاری هوشمند را ارائه میکنند، که به شما امکان میدهد آزمایشها را بر اساس سابقه آزمایش قبلیتان بهطور بهینه بین قطعات تقسیم کنید. با شاردینگ هوشمند، خردهها تقریباً به همان مدت زمان کار میکنند و نتایج آزمایش را در سریعترین زمان ممکن برمیگردانند. اشتراک گذاری هوشمند به شما امکان می دهد مجموعه های آزمایشی بزرگ را به صورت موازی اجرا کنید و این ویژگی را برای جریان های CI/CD مناسب می کند.
تاریخ آخرین بهروزرسانی 2025-09-04 بهوقت ساعت هماهنگ جهانی.
[[["درک آسان","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 بهوقت ساعت هماهنگ جهانی."],[],[],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."]]