Effective in 2026, to align with our trunk stable development model and ensure platform stability for the ecosystem, we will publish source code to AOSP in Q2 and Q4. For building and contributing to AOSP, we recommend utilizing android-latest-release instead of aosp-main. The android-latest-release manifest branch will always reference the most recent release pushed to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
HostUtils
public
final
class
HostUtils
extends Object
| java.lang.Object
|
| ↳ |
com.android.tradefed.lite.HostUtils
|
Implements some useful utility methods for running host tests.
This implements a few methods for finding tests on the host and faking execution of JUnit
tests so we can "dry run" them.
Summary
Public methods |
static
List<Class<?>>
|
getJUnitClasses(Set<String> classNames, Set<String> jarAbsPaths, ClassLoader pcl)
|
static
List<Class<?>>
|
getJUnitClasses(Set<String> classNames, Set<String> jarAbsPaths, List<String> excludePaths, ClassLoader pcl)
Gets JUnit4 test cases from provided classnames and jar paths.
|
static
boolean
|
hasJUnitAnnotation(Class<?> classObj)
Checks whether a class looks like a JUnit test or not.
|
static
boolean
|
testLoadClass(String className, URLClassLoader cl, String jarName)
Tests whether the class is a suitable test class or not.
|
Public methods
getJUnitClasses
public static List<Class<?>> getJUnitClasses (Set<String> classNames,
Set<String> jarAbsPaths,
ClassLoader pcl)
| Parameters |
classNames |
Set |
jarAbsPaths |
Set |
pcl |
ClassLoader |
| Throws |
IllegalArgumentException |
|
getJUnitClasses
public static List<Class<?>> getJUnitClasses (Set<String> classNames,
Set<String> jarAbsPaths,
List<String> excludePaths,
ClassLoader pcl)
Gets JUnit4 test cases from provided classnames and jar paths.
| Parameters |
classNames |
Set: Classes that exist in the current class path to check for JUnit tests |
jarAbsPaths |
Set: Jars to search for classes with the test annotations. |
excludePaths |
List |
pcl |
ClassLoader |
| Returns |
List<Class<?>> |
a list of class objects that are test classes to execute. |
| Throws |
|
java.lang.IllegalArgumentException |
IllegalArgumentException |
|
hasJUnitAnnotation
public static boolean hasJUnitAnnotation (Class<?> classObj)
Checks whether a class looks like a JUnit test or not.
| Parameters |
classObj |
Class: Class to examine for the annotation |
| Returns |
boolean |
whether the class object has the JUnit4 test annotation |
testLoadClass
public static boolean testLoadClass (String className,
URLClassLoader cl,
String jarName)
Tests whether the class is a suitable test class or not.
In this case, suitable means it is a valid JUnit test class using one of the standard
runners or a subclass thereof. The class should also load, obviously.
| Returns |
boolean |
true if we should consider this class a test class, false otherwise |
| Throws |
IllegalArgumentException |
|
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2026-06-22 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-06-22 UTC."],[],[]]