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
        
        
        
     | 
  
    
      
      getJUnitClasses(
      
     | 
  
        
        
        static
        
        
        
     | 
  
    
      
      getJUnitClasses(
      
        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 staticgetJUnitClasses ( classNames, jarAbsPaths, ClassLoader pcl) 
| Parameters | |
|---|---|
classNames | 
        
            | 
      
jarAbsPaths | 
        
            | 
      
pcl | 
        
          ClassLoader  | 
      
| Returns | |
|---|---|
 | 
        |
getJUnitClasses
public staticgetJUnitClasses ( classNames, jarAbsPaths, excludePaths, ClassLoader pcl) 
Gets JUnit4 test cases from provided classnames and jar paths.
| Parameters | |
|---|---|
classNames | 
        
          : Classes that exist in the current class path to check for JUnit tests | 
      
jarAbsPaths | 
        
          : Jars to search for classes with the test annotations. | 
      
excludePaths | 
        
            | 
      
pcl | 
        
          ClassLoader  | 
      
| Returns | |
|---|---|
 | 
        a list of class objects that are test classes to execute. | 
| Throws | |
|---|---|
 | 
          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 |