اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
بنية أداة تنفيذ الاختبار
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
أداة تنفيذ الاختبار هي وحدة التنفيذ لمسار الاستدعاء. هذا هو المكان الذي يتم فيه تنفيذ الاختبار.
واجهات
يتم تحديد مشغّلي الاختبار من خلال واجهة IRemoteTest،
التي توفّر طريقة run
بسيطة لتنفيذها سيتمّ استدعاؤها عند تنفيذ
الاختبارات.
يتيح ذلك تنفيذ أبسط تعريف لتشغيل الاختبار. ولكن في الممارسة العملية، يحتاج مؤلفو الاختبار إلى مزيد من المعلومات لكتابة اختباراتهم بشكل صحيح، وعادةً ما تكون هذه المعلومات متعلّقة بالإصدار والجهاز. هذا هو المكان الذي تكون فيه الواجهات التالية مفيدة.
الإعدادات الأساسية
هاتان الواجهتَان هما الأكثر استخدامًا اليوم، لأنّهما تمثّلان الاحتياجات الأساسية
لمعظم الاختبارات.
- يسمح IBuildReceiver
للاختبار بالحصول على عنصر
IBuildInfo
الذي تم إنشاؤه في خطوة موفِّر
البناء
التي تحتوي على جميع المعلومات والعناصر ذات الصلة بإعداد الاختبار.
- يسمح IDeviceTest
لـ TF بتلقّي عنصر
ITestDevice
الذي يمثّل الجهاز
قيد الاختبار، كما يوفّر واجهة برمجة تطبيقات للتفاعل معه.
الإعدادات المتقدّمة
هناك واجهات إضافية تسمح بتفاعل أكثر تعقيدًا بين
مجموعة أدوات الاختبار وبرنامج تشغيل الاختبار:
- ITestFilterReceiver،
الذي يسمح للاختبار بتلقّي مجموعة من الفلاتر لتشغيل اختبارات معيّنة
فقط يكون ذلك مفيدًا في تنفيذ مجموعة فرعية من الاختبارات.
- ITestCollector،
الذي يسمح لمسؤول تنفيذ الاختبارات بإجراء عمليات محاكاة للاختبارات فقط بدلاً من تنفيذها فعليًا
ويُعدّ ذلك مفيدًا في جمع قائمة بجميع حالات الاختبار.
مشغّلو الاختبارات الحاليون
تتوفّر حاليًا مجموعة متنوعة من مشغّلات الاختبارات، وبعضها مخصّص لأنواع الاختبارات الرئيسية:
بالإضافة إلى ما سبق، يتوفّر عدد كبير من مشغّلات الاختبار المخصّصة، وهي تخدم
أغراضًا متخصّصة لبعض الاختبارات الوظيفية، مثل اختبار التشغيل.
كتابة أداة جديدة لتشغيل الاختبارات
تتوفّر المزيد من الإرشادات حول كتابة أداة جديدة لتشغيل الاختبارات في قسم كتابة الاختبارات.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-07-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","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-07-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Structure of a test runner\n\nThe test runner is the execution unit of the invocation flow. This is where\ntests actually run.\n\nInterfaces\n----------\n\nTest runners are defined via the [IRemoteTest\ninterface](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/invocation_interfaces/com/android/tradefed/testtype/IRemoteTest.java),\nwhich provides a simple `run` method to implement that will be called when the\ntests is to run.\n\nThis allows the simplest definition of a test run to occur. But in practice,\ntest writers will need more information to properly write their tests, typically\nbuild and device information. This is where the following interfaces come handy.\n\n### Basic\n\nThese two interfaces are the most widely used today, as they represent the basic\nneeds of most tests.\n\n- [IBuildReceiver](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/IBuildReceiver.java) allows the test to get the `IBuildInfo` object created at the [build\n provider](/docs/core/tests/tradefed/architecture/build-provider) step containing all the information and artifacts related to the test setup.\n- [IDeviceTest](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/IDeviceTest.java) allows TF to receive the `ITestDevice` object that represents the device under test and provides an API to interact with it.\n\n### Advanced\n\nThere are additional interfaces that allow more complex interaction between the\ntest harness and the test runner:\n\n- [ITestFilterReceiver](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/ITestFilterReceiver.java), which allows the test to receive a set of filters for running certain tests only. This is useful in running a subset of the tests.\n- [ITestCollector](https://android.googlesource.com/platform/tools/tradefederation/+/refs/heads/android16-release/src/com/android/tradefed/testtype/ITestCollector.java), which allows a test runner to only dry-run the tests instead of actually executing them. This is useful in collecting the list of all test cases.\n\nExisting test runners\n---------------------\n\nA variety of test runners already exists, some for major test types:\n\n- [AndroidJUnitTest / InstrumentationTest](/reference/tradefed/com/android/tradefed/testtype/AndroidJUnitTest) (associated with AJUR on the device side)\n- [GTest](/reference/tradefed/com/android/tradefed/testtype/GTest) (device and host side) with [googletest library](https://github.com/google/googletest)\n- [Host-driven\n tests](/reference/tradefed/com/android/tradefed/testtype/HostTest) (Java tests that execute on the host and call the device from there)\n- [Pure Java unit\n tests](/reference/tradefed/com/android/tradefed/testtype/HostTest) (our runner does both)\n- [Python tests](/reference/tradefed/com/android/tradefed/testtype/python/PythonBinaryHostTest)\n- [Google Benchmark\n tests](/reference/tradefed/com/android/tradefed/testtype/GoogleBenchmarkTest) with [benchmark library](https://github.com/google/benchmark)\n\nA large number of custom test runners exist besides the above; they serve\nspecialized purposes for some functional testing, for example Boot Test.\n\nWrite a new test runner\n-----------------------\n\nMore guidance of writing a new test runner is available in the [writing tests\nsection](/docs/core/tests/tradefed/testing/through-tf/new-test-runner)."]]