HostTest
public
class
HostTest
extends Object
implements
IAbiReceiver,
IBuildReceiver,
IConfigurationReceiver,
IDeviceTest,
IDiscoverTestClasses,
IRemoteTest,
IRuntimeHintProvider,
IShardableTest,
ITestAnnotationFilterReceiver,
ITestCollector,
ITestFilterReceiver
| java.lang.Object | |
| ↳ | com.android.tradefed.testtype.HostTest |
Un esecutore test per i test basati sull'host JUnit. Se il test da eseguire implementa IDeviceTest
questo runner passerà un riferimento al dispositivo.
Riepilogo
Costanti | |
|---|---|
String |
SET_OPTION_DESC
|
String |
SET_OPTION_NAME
|
Costruttori pubblici | |
|---|---|
HostTest()
|
|
Metodi pubblici | |
|---|---|
void
|
addAllExcludeAnnotation(Set<String> notAnnotations)
Aggiunge un |
void
|
addAllExcludeFilters(Set<String> filters)
Aggiunge il |
void
|
addAllIncludeAnnotation(Set<String> annotations)
Aggiunge un |
void
|
addAllIncludeFilters(Set<String> filters)
Aggiunge il |
void
|
addExcludeAnnotation(String notAnnotation)
Aggiunge un'annotazione da escludere se un test è contrassegnato con questa annotazione. |
void
|
addExcludeFilter(String filter)
Aggiunge un filtro per i test da escludere. |
void
|
addIncludeAnnotation(String annotation)
Aggiunge un'annotazione da includere se un test è contrassegnato. |
void
|
addIncludeFilter(String filter)
Aggiunge un filtro per i test da includere. |
void
|
clearExcludeAnnotations()
Elimina tutte le annotazioni di esclusione attualmente monitorate. |
void
|
clearExcludeFilters()
Elimina tutti i filtri di esclusione attualmente monitorati. |
void
|
clearIncludeAnnotations()
Elimina tutte le annotazioni di inclusione attualmente monitorate. |
void
|
clearIncludeFilters()
Elimina tutti i filtri di inclusione attualmente monitorati. |
int
|
countTestCases()
Restituisce il numero di scenari di test in tutte le classi che fanno parte dei test |
IAbi
|
getAbi()
|
Set<String>
|
getClassNames()
|
ITestDevice
|
getDevice()
Ottieni il dispositivo in fase di test. |
Set<String>
|
getExcludeAnnotations()
Restituisce l' |
Set<String>
|
getExcludeFilters()
Restituisce l'attuale |
Set<String>
|
getIncludeAnnotations()
Restituisce l' |
Set<String>
|
getIncludeFilters()
Restituisce l' |
long
|
getRuntimeHint()
Restituisce la durata prevista del test in millisecondi. |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
Esegue i test e comunica il risultato al listener. |
void
|
setAbi(IAbi abi)
|
void
|
setBuild(IBuildInfo buildInfo)
|
void
|
setCollectTestsOnly(boolean shouldCollectTest)
Attiva o disattiva la modalità di raccolta dei test |
void
|
setConfiguration(IConfiguration configuration)
Inserisce il |
void
|
setDevice(ITestDevice device)
Inserisci il dispositivo in fase di test. |
static
void
|
setOptionToLoadedObject(Object testObj, List<String> keyValueOptions)
Helper per Device Runner da utilizzare per impostare le opzioni nello stesso modo di HostTest, da set-option. |
void
|
setTestInformation(TestInformation testInfo)
|
Collection<IRemoteTest>
|
split(Integer shardCount, TestInformation testInfo)
Dividiamo per individuo in base alla classe di test o al metodo. |
Metodi protetti | |
|---|---|
HostTest
|
createHostTest(Class<?> classObj)
Helper per creare un'istanza HostTest durante lo sharding. |
IBuildInfo
|
getBuild()
Ottieni le informazioni sulla build ricevute da HostTest. |
ClassLoader
|
getClassLoader()
Restituisce il class loader predefinito. |
final
List<Class<?>>
|
getClasses()
|
File
|
getJarFile(String jarName, TestInformation testInfo)
Ispeziona diverse posizioni in cui si trovano solitamente gli artefatti per diversi casi d'uso per trovare il nostro file JAR. |
boolean
|
hasJUnit4Annotation(Class<?> classObj)
Helper per determinare se stiamo gestendo una classe di test con annotazioni Junit4. |
Object
|
loadObject(Class<?> classObj)
carica l'oggetto classe e imposta le informazioni di test (dispositivo, build). |
void
|
setClassName(String className)
Cancella e imposta un nome di classe da eseguire. |
void
|
setMethodName(String methodName)
Imposta il nome del metodo da eseguire. |
boolean
|
shouldTestRun(AnnotatedElement annotatedElement)
Controlla se un elemento con annotazione supera il filtro. |
Costanti
SET_OPTION_DESC
public static final String SET_OPTION_DESC
Valore costante:
"Opzioni da trasmettere alla classe in fase di test, chiave e valore devono essere separati dai due punti ":"; ad esempio, se la classe in fase di test supporta "--iteration 1" da una riga di comando, deve essere trasmessa come "--set-option iteration:1" o "--set-option iteration:key=value" per trasmettere le opzioni alla mappa. I valori che contengono ":" o "=" possono essere preceduti da una barra rovesciata. È possibile scegliere come target una classe specifica. " --set-option
SET_OPTION_NAME
public static final String SET_OPTION_NAME
Valore costante: "set-option"
Costruttori pubblici
HostTest
public HostTest ()
Metodi pubblici
addAllExcludeAnnotation
public void addAllExcludeAnnotation (Set<String> notAnnotations)
Aggiunge un Set di annotazioni da escludere se un test è contrassegnato con questo valore.
| Parametri | |
|---|---|
notAnnotations |
Set |
addAllExcludeFilters
public void addAllExcludeFilters (Set<String> filters)
Aggiunge il Set dei filtri dei test da escludere.
| Parametri | |
|---|---|
filters |
Set |
addAllIncludeAnnotation
public void addAllIncludeAnnotation (Set<String> annotations)
Aggiunge un Set di annotazioni da includere se un test è contrassegnato con questo valore.
| Parametri | |
|---|---|
annotations |
Set |
addAllIncludeFilters
public void addAllIncludeFilters (Set<String> filters)
Aggiunge il Set dei filtri dei test da includere.
| Parametri | |
|---|---|
filters |
Set |
addExcludeAnnotation
public void addExcludeAnnotation (String notAnnotation)
Aggiunge un'annotazione da escludere se un test è contrassegnato con questa annotazione.
| Parametri | |
|---|---|
notAnnotation |
String |
addExcludeFilter
public void addExcludeFilter (String filter)
Aggiunge un filtro per i test da escludere.
| Parametri | |
|---|---|
filter |
String |
addIncludeAnnotation
public void addIncludeAnnotation (String annotation)
Aggiunge un'annotazione da includere se un test è contrassegnato.
| Parametri | |
|---|---|
annotation |
String |
addIncludeFilter
public void addIncludeFilter (String filter)
Aggiunge un filtro per i test da includere.
| Parametri | |
|---|---|
filter |
String |
clearExcludeAnnotations
public void clearExcludeAnnotations ()
Elimina tutte le annotazioni di esclusione attualmente monitorate.
clearExcludeFilters
public void clearExcludeFilters ()
Elimina tutti i filtri di esclusione attualmente monitorati.
clearIncludeAnnotations
public void clearIncludeAnnotations ()
Elimina tutte le annotazioni di inclusione attualmente monitorate.
clearIncludeFilters
public void clearIncludeFilters ()
Elimina tutti i filtri di inclusione attualmente monitorati.
countTestCases
public int countTestCases ()
Restituisce il numero di scenari di test in tutte le classi che fanno parte dei test
| Resi | |
|---|---|
int |
|
getClassNames
public Set<String> getClassNames ()
| Resi | |
|---|---|
Set<String> |
|
getDevice
public ITestDevice getDevice ()
Ottieni il dispositivo in fase di test.
| Resi | |
|---|---|
ITestDevice |
ITestDevice |
getExcludeAnnotations
public Set<String> getExcludeAnnotations ()
Restituisce l'Set corrente delle annotazioni da escludere.
| Resi | |
|---|---|
Set<String> |
|
getExcludeFilters
public Set<String> getExcludeFilters ()
Restituisce l'attuale Set dei filtri di esclusione.
| Resi | |
|---|---|
Set<String> |
|
getIncludeAnnotations
public Set<String> getIncludeAnnotations ()
Restituisce l'Set corrente delle annotazioni da includere.
| Resi | |
|---|---|
Set<String> |
|
getIncludeFilters
public Set<String> getIncludeFilters ()
Restituisce l'Set corrente dei filtri di inclusione.
| Resi | |
|---|---|
Set<String> |
|
getRuntimeHint
public long getRuntimeHint ()
Restituisce la durata prevista del test in millisecondi. Il tempo viene utilizzato per bilanciare il carico dell'esecuzione suddivisa in shard
| Resi | |
|---|---|
long |
|
run
public void run (TestInformation testInfo, ITestInvocationListener listener)
Esegue i test e comunica il risultato al listener.
| Parametri | |
|---|---|
testInfo |
TestInformation: l'oggetto TestInformation contenente informazioni utili per eseguire i test. |
listener |
ITestInvocationListener: il ITestInvocationListener dei risultati del test |
| Genera | |
|---|---|
DeviceNotAvailableException |
|
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
Attiva o disattiva la modalità di raccolta dei test
setConfiguration
public void setConfiguration (IConfiguration configuration)
Inserisce il IConfiguration in uso.
| Parametri | |
|---|---|
configuration |
IConfiguration |
setDevice
public void setDevice (ITestDevice device)
Inserisci il dispositivo in fase di test.
| Parametri | |
|---|---|
device |
ITestDevice: il ITestDevice da utilizzare |
setOptionToLoadedObject
public static void setOptionToLoadedObject (Object testObj,
List<String> keyValueOptions)Helper per Device Runner da utilizzare per impostare le opzioni nello stesso modo di HostTest, da set-option.
| Parametri | |
|---|---|
testObj |
Object: l'oggetto che riceverà le opzioni. |
keyValueOptions |
List: l'elenco delle opzioni formattato come richiesto da HostTest set-option. |
setTestInformation
public void setTestInformation (TestInformation testInfo)
| Parametri | |
|---|---|
testInfo |
TestInformation |
ripartire
public Collection<IRemoteTest> split (Integer shardCount, TestInformation testInfo)
Dividiamo per individuo in base alla classe di test o al metodo.
| Parametri | |
|---|---|
shardCount |
Integer: il numero di shard tentato. |
testInfo |
TestInformation: Il genitore TestInformation |
| Resi | |
|---|---|
Collection<IRemoteTest> |
una raccolta di test secondari da eseguire separatamente o null se il test
non è attualmente suddivisibile |
Metodi protetti
createHostTest
protected HostTest createHostTest (Class<?> classObj)
Helper per creare un'istanza HostTest durante lo sharding. Esegui l'override per restituire qualsiasi elemento figlio da HostTest.
| Parametri | |
|---|---|
classObj |
Class |
| Resi | |
|---|---|
HostTest |
|
getBuild
protected IBuildInfo getBuild ()
Ottieni le informazioni sulla build ricevute da HostTest.
| Resi | |
|---|---|
IBuildInfo |
IBuildInfo |
getClassLoader
protected ClassLoader getClassLoader ()
Restituisce il class loader predefinito.
| Resi | |
|---|---|
ClassLoader |
|
getClasses
protected final List<Class<?>> getClasses ()
| Resi | |
|---|---|
List<Class<?>> |
|
| Genera | |
|---|---|
IllegalArgumentException |
|
getJarFile
protected File getJarFile (String jarName,
TestInformation testInfo)Ispeziona diverse posizioni in cui si trovano solitamente gli artefatti per diversi casi d'uso per trovare il nostro file JAR.
| Parametri | |
|---|---|
jarName |
String |
testInfo |
TestInformation |
| Resi | |
|---|---|
File |
|
| Genera | |
|---|---|
FileNotFoundException |
|
hasJUnit4Annotation
protected boolean hasJUnit4Annotation (Class<?> classObj)
Helper per determinare se stiamo gestendo una classe di test con annotazioni Junit4.
| Parametri | |
|---|---|
classObj |
Class |
| Resi | |
|---|---|
boolean |
|
loadObject
protected Object loadObject (Class<?> classObj)
carica l'oggetto classe e imposta le informazioni di test (dispositivo, build).
| Parametri | |
|---|---|
classObj |
Class |
| Resi | |
|---|---|
Object |
|
setClassName
protected void setClassName (String className)
Cancella e imposta un nome di classe da eseguire.
| Parametri | |
|---|---|
className |
String |
setMethodName
protected void setMethodName (String methodName)
Imposta il nome del metodo da eseguire.
Questo attributo viene utilizzato per eseguire un metodo di test specifico da una classe di test.
| Parametri | |
|---|---|
methodName |
String |
shouldTestRun
protected boolean shouldTestRun (AnnotatedElement annotatedElement)
Controlla se un elemento con annotazione supera il filtro. Esposto per il test delle unità.
| Resi | |
|---|---|
boolean |
false se il test non deve essere eseguito. |