testing-setup
ما الذي تفعله
تفحص هذه المهارة كيف يختبر مشروع Android شيفرته اليوم، وتخطط لإعداد اختبارات. ويمكنها إضافة مكتبات الاختبار وأدوات التشغيل لاختبارات الوحدة وواجهة المستخدم ولقطات الشاشة والاختبارات الشاملة. وهي موجهة لمطوري Android الذين يريدون استراتيجية اختبار عملية.
متى تستخدمها
- ✓عندما يحتوي مشروع Android لديك على اختبارات قليلة أو لا يحتوي عليها، وتريد إعدادًا للاختبار.
- ✓عندما تريد إضافة اختبارات لقطات شاشة لشاشات Compose أو View.
- ✓عندما تحتاج إلى معرفة مكتبات الاختبار وأدوات المحاكاة التي يستخدمها مشروعك بالفعل.
رابط المهارة
https://github.com/android/skills/blob/main/testing/testing-setup/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“اطّلع على إعداد الاختبارات في مشروع Android لدي، وأضف المكتبات لاختبارات الوحدة واختبارات Compose.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تقرأ المهارة كتالog الإصدارات وملفات البناء لتجد إطار حقن التبعيات، وأطر الاختبار، وأدوات المحاكاة، ونوع واجهة المستخدم. ثم تضيف المكتبات وأدوات التشغيل الناقصة التي تناسب المشروع.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
Step 1: Analyze the current testing setup
To understand the testing setup of an existing project, look for these dependencies in the libs.versions.toml file, or build files:
- Dependency Injection framework used. For example, Hilt, Koin, Anvil, or vanilla Dagger.
- Unit (local) testing framework this project uses. For example, JUnit4 or JUnit5.
- Mocking framework (if any) used for unit tests, and for instrumented and UI tests. For example, Mockito or Mockk.
- Robolectric. Identify which of these three uses apply:
- Used in unit tests to have fakes for platform entities
- To run behavior UI tests without a device or emulator. For example, used to run Espresso or Compose tests.
- To do screenshot testing with Roborazzi
- Is the app 100% Compose, Views or hybrid?
- Behavior UI tests:
- Compose Tests (
androidx.compose.ui:ui-test-*) - Espresso Tests for Views. Check for wrappers such as Kaspresso. Dependencies:
androidx.test.espresso:espresso-core,androidx.test:runner,androidx.test:rules.
- Compose Tests (
- Screenshot tests. Identify which of these types the project uses:
- Instrumented (device-based). For example, using Dropshots.
- Based on Robolectric, so they run locally. For example, using Roborazzi.
- Based on LayoutLib, so they run locally. For example, Paparazzi, or the Compose Preview Screenshot Testing tool.
- End to end tests (also known as Release Candidate tests) always run on device and use high-level frameworks such as UIAutomator, Appium, or Robotium.
- Generate a Markdown report with the analysis
Step 2: Set up Dependency Injection frameworks for testing
If there is no Dependency Injection framework, install one: if it's a multiplatform application, ask the user whether they want to install Koin, or kotlin-inject. If it's not multiplatform, install Hilt.
Install the testing dependencies (for example com.google.dagger:hilt-compiler
that should be applied with a kspAndroidTest configuration).
[!IMPORTANT] Important: Always consult the documentation of the applicable framework to learn about testing (for example: Hilt testing guide, Koin Instrumented tests).
For instrumented tests, create and configure (by adding
testInstrumentationRunner to the build gradle files) a new test runner and
apply the testing rules required by the framework (for example in Hilt, annotate
your test classes with @HiltAndroidTest and apply the HiltAndroidRule).
Other frameworks use other mechanisms, consult their documentation.
Step 3: Install frameworks
Unless otherwise specified, respect the current stack of testing frameworks.
If there are no testing frameworks, and the user didn't specify any preference, install the following:
JUnit4 for local and instrumented tests
JaCoCo for test coverage
For UI tests: if the project has views, Espresso. If it's fully Compose, use the Compose Testing APIs.
Robolectric to run UI Tests
Compose Preview Screenshot Testing tool for screenshot tests. Check the project's AGP version first, then pick the matching setup and follow it strictly:
- AGP 9.5.0-alpha03 or higher (recommended): configure an AGP test suite using
testOptions { screenshotTests.create(...) }, as described in Screenshot testing with test suites. - Lower AGP versions: use the legacy standalone plugin setup with
com.android.compose.screenshot, and tell the user it's deprecated. Don't upgrade AGP as part of setting up screenshot tests. Mention that test suites are available on 9.5.0-alpha03 or higher, and leave the upgrade as a separate decision.
Don't combine both setups in the same module. If the project already uses the standalone plugin and its AGP version supports test suites, offer to migrate it using the tasks and paths mapping table in Screenshot testing with test suites.
- AGP 9.5.0-alpha03 or higher (recommended): configure an AGP test suite using
Dropshots for device screenshot tests
If a mocking framework is necessary, install Mockk (
io.mockk:mockk). Do not install it unless it is clearly necessary.
If instrumented screenshot tests are requested, install Dropshots.
If end-to-end testing is requested, install
الأسئلة الشائعة
هل تكتب حالات الاختبار الفعلية لدي؟
تركّز المهارة على إعداد الاختبار وأدوات التشغيل، لذلك ما زلت تقرر السلوكيات التي تختبرها.
ما أنواع اختبارات اللقطات التي تعرفها؟
تتعرف على اختبارات اللقطات المعتمدة على الأجهزة، والمحلية المعتمدة على Robolectric أو LayoutLib.
ما أدوات حقن التبعيات التي تتعرف عليها؟
تتعرف على أطر مثل Hilt وKoin وAnvil وDagger العادي.
التفاصيل
الوصف الأصلي من المؤلف
Analyze and create a testing strategy for Android apps - install testing libraries, set up test infrastructure, create harnesses for unit tests, UI tests, screenshot tests, and end-to-end tests.
repo: android/skills
الشعبية
- نجوم GitHub
- 10k
- الترتيب
- #11937
- الترخيص
- Apache-2.0
- آخر تحديث
- 29/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
agp-9-upgrade
10kيساعد وكيلك على ترقية تطبيق Android إلى Android Gradle Plugin 9 ومعالجة التغييرات الجذرية فيه. لا يناسب مشاريع Multiplatform.
camerax
10kيساعد وكيلك على بناء ميزات الكاميرا في Android باستخدام CameraX، بما في ذلك تسجيل الفيديو وأدوات الأجهزة وتأثيرات ML Kit وMedia3.
android-for-cars-parked-apps
10kيساعد وكيلك على تكييف تطبيق فيديو أو لعبة أو متصفح في Android ليعمل كتطبيق متوقف على Android Auto وAndroid Automotive.
appfunctions
10kيساعد وكيلك على إيجاد أهم المسارات في تطبيق Android وعرضها كـ AppFunctions يمكن لوكلاء الذكاء الاصطناعي وأوامر الصوت تشغيلها.
مهارات مشابهة
test-driven-development
311kيعلّم وكيلك كتابة اختبار فاشل أولًا، ثم رؤيته يفشل، ثم كتابة أصغر شيفرة تنجحه، قبل بناء أي ميزة أو إصلاح.
verification-before-completion
311kيعلّم وكيلك تشغيل فحوصات حقيقية وقراءة نتائجها قبل أن يقول إن المهمة أو الإصلاح أو البناء مكتمل أو ناجح.
migrate-to-shoehorn
310kيستبدل تأكيدات النوع الخطرة في ملفات الاختبار بمكتبة shoehorn، حتى تتمكن الاختبارات من استخدام بيانات جزئية وتجتاز فحوص الأنواع.