اعتبارًا من 27 آذار (مارس) 2025، ننصحك باستخدام android-latest-release
بدلاً من aosp-main
لإنشاء AOSP والمساهمة فيه. لمزيد من المعلومات، يُرجى الاطّلاع على التغييرات في AOSP.
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
HostUtils
public
final
class
HostUtils
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.lite.HostUtils
|
تُنفِّذ بعض طرق المرافق المفيدة لإجراء اختبارات المضيف.
ينفِّذ هذا الإجراء بعض الطرق للعثور على الاختبارات على المضيف وتنفيذ اختبارات JUnit
بشكل اصطناعي لنتمكّن من "تجربتها".
ملخّص
الطرق العامة |
static
|
getJUnitClasses( classNames, jarAbsPaths, ClassLoader pcl)
|
static
|
getJUnitClasses( classNames, jarAbsPaths, excludePaths, ClassLoader pcl)
تحصل على حالات اختبار JUnit4 من أسماء الفئات ومسارات jar المقدَّمة.
|
static
boolean
|
hasJUnitAnnotation(Class<?> classObj)
للتحقّق مما إذا كانت الفئة تبدو مثل اختبار JUnit أم لا
|
static
boolean
|
testLoadClass(String className, URLClassLoader cl, String jarName)
لاختبار ما إذا كانت الفئة هي فئة اختبار مناسبة أم لا
|
الطرق العامة
getJUnitClasses
public static getJUnitClasses ( classNames,
jarAbsPaths,
ClassLoader pcl)
المعلمات |
classNames |
|
jarAbsPaths |
|
pcl |
ClassLoader |
getJUnitClasses
public static getJUnitClasses ( classNames,
jarAbsPaths,
excludePaths,
ClassLoader pcl)
تحصل على حالات اختبار JUnit4 من أسماء الفئات ومسارات jar المقدَّمة.
المعلمات |
classNames |
: الفصول الدراسية المتوفّرة في مسار الفئة الحالي للتحقّق من اختبارات JUnit |
jarAbsPaths |
: حِزم للبحث عن الصفوف التي تحتوي على التعليقات التوضيحية للاختبار |
excludePaths |
|
pcl |
ClassLoader |
المرتجعات |
|
قائمة بكائنات الفئات التي هي فئات اختبارية لتنفيذها |
عمليات الرمي |
|
IllegalArgumentException |
hasJUnitAnnotation
public static boolean hasJUnitAnnotation (Class<?> classObj)
للتحقّق مما إذا كانت الفئة تبدو مثل اختبار JUnit أم لا
المعلمات |
classObj |
Class : الفئة المطلوب فحصها بحثًا عن التعليق التوضيحي |
المرتجعات |
boolean |
ما إذا كان كائن الفئة يتضمّن التعليق التوضيحي لاختبار JUnit4 |
testLoadClass
public static boolean testLoadClass (String className,
URLClassLoader cl,
String jarName)
لاختبار ما إذا كانت الفئة هي فئة اختبار مناسبة أم لا
في هذه الحالة، تعني كلمة "مناسبة" أنّها فئة اختبار JUnit صالحة تستخدم أحد مشغّلات
العادية أو فئة فرعية منها. من المفترض أيضًا أن يتم تحميل الصف.
المرتجعات |
boolean |
صحيح إذا كان علينا اعتبار هذه الفئة فئة اختبار، خطأ في الحالات الأخرى |
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ 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,["# HostUtils\n=========\n\n\n`\npublic\n\nfinal\n\nclass\nHostUtils\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|-------------------------------------|\n| java.lang.Object ||\n| ↳ | com.android.tradefed.lite.HostUtils |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nImplements some useful utility methods for running host tests.\n\nThis implements a few methods for finding tests on the host and faking execution of JUnit\ntests so we can \"dry run\" them.\n\nSummary\n-------\n\n| ### Public methods ||\n|-------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static ` | ` `[getJUnitClasses](../../../../../../reference/tradefed/com/android/tradefed/lite/HostUtils.html#getJUnitClasses(\u003cany\u003e,%20\u003cany\u003e,%20java.lang.ClassLoader))`(` classNames, jarAbsPaths, ClassLoader pcl) |\n| ` static ` | ` `[getJUnitClasses](../../../../../../reference/tradefed/com/android/tradefed/lite/HostUtils.html#getJUnitClasses(\u003cany\u003e,%20\u003cany\u003e,%20\u003cany\u003e,%20java.lang.ClassLoader))`(` classNames, jarAbsPaths, excludePaths, ClassLoader pcl) Gets JUnit4 test cases from provided classnames and jar paths. |\n| ` static boolean` | ` `[hasJUnitAnnotation](../../../../../../reference/tradefed/com/android/tradefed/lite/HostUtils.html#hasJUnitAnnotation(java.lang.Class\u003c?\u003e))`(Class\u003c?\u003e classObj) ` Checks whether a class looks like a JUnit test or not. |\n| ` static boolean` | ` `[testLoadClass](../../../../../../reference/tradefed/com/android/tradefed/lite/HostUtils.html#testLoadClass(java.lang.String,%20URLClassLoader,%20java.lang.String))`(String className, URLClassLoader cl, String jarName) ` Tests whether the class is a suitable test class or not. |\n\nPublic methods\n--------------\n\n### getJUnitClasses\n\n```\npublic static getJUnitClasses ( classNames, \n jarAbsPaths, \n ClassLoader pcl)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|----------------------|\n| `classNames` | \u003cbr /\u003e |\n| `jarAbsPaths` | \u003cbr /\u003e |\n| `pcl` | `ClassLoader` \u003cbr /\u003e |\n\n| Returns ||\n|---|--------|\n| | \u003cbr /\u003e |\n\n### getJUnitClasses\n\n```\npublic static getJUnitClasses ( classNames, \n jarAbsPaths, \n excludePaths, \n ClassLoader pcl)\n```\n\nGets JUnit4 test cases from provided classnames and jar paths.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|----------------|--------------------------------------------------------------------------------|\n| `classNames` | : Classes that exist in the current class path to check for JUnit tests \u003cbr /\u003e |\n| `jarAbsPaths` | : Jars to search for classes with the test annotations. \u003cbr /\u003e |\n| `excludePaths` | \u003cbr /\u003e |\n| `pcl` | `ClassLoader` \u003cbr /\u003e |\n\n| Returns ||\n|---|------------------------------------------------------------------|\n| | a list of class objects that are test classes to execute. \u003cbr /\u003e |\n\n| Throws ||\n|---|--------------------------|\n| | IllegalArgumentException |\n\n### hasJUnitAnnotation\n\n```\npublic static boolean hasJUnitAnnotation (Class\u003c?\u003e classObj)\n```\n\nChecks whether a class looks like a JUnit test or not.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|-----------------------------------------------------|\n| `classObj` | `Class`: Class to examine for the annotation \u003cbr /\u003e |\n\n| Returns ||\n|-----------|----------------------------------------------------------------|\n| `boolean` | whether the class object has the JUnit4 test annotation \u003cbr /\u003e |\n\n### testLoadClass\n\n```\npublic static boolean testLoadClass (String className, \n URLClassLoader cl, \n String jarName)\n```\n\nTests whether the class is a suitable test class or not.\n\nIn this case, suitable means it is a valid JUnit test class using one of the standard\nrunners or a subclass thereof. The class should also load, obviously.\n\n\u003cbr /\u003e\n\n| Returns ||\n|-----------|----------------------------------------------------------------------------|\n| `boolean` | true if we should consider this class a test class, false otherwise \u003cbr /\u003e |"]]