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


JUnit ホストベースのテスト用のテストランナー。実行するテストが IDeviceTest を実装している場合、このランナーはデバイスへの参照を渡します。

概要

定数

String SET_OPTION_DESC

String SET_OPTION_NAME

パブリック コンストラクタ

HostTest()

パブリック メソッド

void addAllExcludeAnnotation(Set<String> notAnnotations)

テストにマークされている場合に除外するアノテーションの Set を追加します。

void addAllExcludeFilters(Set<String> filters)

除外するテストのフィルタの Set を追加します。

void addAllIncludeAnnotation(Set<String> annotations)

テストがマークされている場合に含めるアノテーションの Set を追加します。

void addAllIncludeFilters(Set<String> filters)

含めるテストのフィルタの Set を追加します。

void addExcludeAnnotation(String notAnnotation)

テストにマークが付いている場合、除外するアノテーションを追加します。

void addExcludeFilter(String filter)

除外するテストのフィルタを追加します。

void addIncludeAnnotation(String annotation)

テストにマークが付いている場合に含めるアノテーションを追加します。

void addIncludeFilter(String filter)

含めるテストのフィルタを追加します。

void clearExcludeAnnotations()

現在トラッキングされている除外アノテーションをすべて削除します。

void clearExcludeFilters()

現在トラッキングされている除外フィルタをすべて削除します。

void clearIncludeAnnotations()

現在トラッキングされているすべてのインクルード アノテーションを削除します。

void clearIncludeFilters()

現在トラッキングされているすべての包含フィルタを削除します。

int countTestCases()

テストの一部であるすべてのクラスのテストケースの数を返します。

IAbi getAbi()

Set<String> getClassNames()
ITestDevice getDevice()

テスト対象デバイスを取得します。

Set<String> getExcludeAnnotations()

除外するアノテーションの現在の Set を返します。

Set<String> getExcludeFilters()

除外フィルタの現在の Set を返します。

Set<String> getIncludeAnnotations()

含めるアノテーションの現在の Set を返します。

Set<String> getIncludeFilters()

現在のインクルード フィルタの Set を返します。

long getRuntimeHint()

テストの想定実行時間をミリ秒単位で返します。

void run(TestInformation testInfo, ITestInvocationListener listener)

テストを実行し、結果をリスナーに報告します。

void setAbi(IAbi abi)

void setBuild(IBuildInfo buildInfo)

void setCollectTestsOnly(boolean shouldCollectTest)

テスト収集モードを有効または無効にします。

void setConfiguration(IConfiguration configuration)

使用中の IConfiguration を挿入します。

void setDevice(ITestDevice device)

テスト対象デバイスを挿入します。

static void setOptionToLoadedObject(Object testObj, List<String> keyValueOptions)

デバイス ランナーが HostTest と同じ方法でオプションを設定するために使用するヘルパー(set-option から)。

void setTestInformation(TestInformation testInfo)
Collection<IRemoteTest> split(Integer shardCount, TestInformation testInfo)

テストクラスまたはメソッドごとに個別に分割します。

保護されたメソッド

HostTest createHostTest(Class<?> classObj)

シャーディング時に HostTest インスタンスを作成するヘルパー。

IBuildInfo getBuild()

HostTest が受信したビルド情報を取得します。

ClassLoader getClassLoader()

デフォルトのクラスローダを返します。

final List<Class<?>> getClasses()
File getJarFile(String jarName, TestInformation testInfo)

さまざまなユースケースでアーティファクトが通常配置される複数の場所を検査して、jar を見つけます。

boolean hasJUnit4Annotation(Class<?> classObj)

Junit4 アノテーション付きのテストクラスを処理しているかどうかを判断するヘルパー。

Object loadObject(Class<?> classObj)

クラス オブジェクトを読み込み、テスト情報(デバイス、ビルド)を設定します。

void setClassName(String className)

実行するクラス名をクリアして設定します。

void setMethodName(String methodName)

実行するメソッド名を設定します。

boolean shouldTestRun(AnnotatedElement annotatedElement)

アノテーションを持つ要素がフィルタを通過するかどうかを確認します。

定数

SET_OPTION_DESC

public static final String SET_OPTION_DESC

定数値: 「テスト対象のクラスに渡されるオプション。キーと値はコロン「:」で区切る必要があります。たとえば、テスト対象のクラスがコマンドラインから「--iteration 1」をサポートしている場合、オプションをマップに渡すには「--set-option iteration:1」または「--set-option iteration:key=value」として渡す必要があります。」「:」または「=」を含む値は、バックスラッシュでエスケープできます。特定のクラスをターゲットにするには、そのクラスを指定します。" --set-option :

SET_OPTION_NAME

public static final String SET_OPTION_NAME

定数値: "set-option"

パブリック コンストラクタ

HostTest

public HostTest ()

パブリック メソッド

addAllExcludeAnnotation

public void addAllExcludeAnnotation (Set<String> notAnnotations)

テストにマークされている場合に除外するアノテーションの Set を追加します。

パラメータ
notAnnotations Set

addAllExcludeFilters

public void addAllExcludeFilters (Set<String> filters)

除外するテストのフィルタの Set を追加します。

パラメータ
filters Set

addAllIncludeAnnotation

public void addAllIncludeAnnotation (Set<String> annotations)

テストがマークされている場合に含めるアノテーションの Set を追加します。

パラメータ
annotations Set

addAllIncludeFilters

public void addAllIncludeFilters (Set<String> filters)

テストに含めるフィルタの Set を追加します。

パラメータ
filters Set

addExcludeAnnotation

public void addExcludeAnnotation (String notAnnotation)

テストにマークが付いている場合に除外するアノテーションを追加します。

パラメータ
notAnnotation String

addExcludeFilter

public void addExcludeFilter (String filter)

除外するテストのフィルタを追加します。

パラメータ
filter String

addIncludeAnnotation

public void addIncludeAnnotation (String annotation)

テストにマークが付いている場合に含めるアノテーションを追加します。

パラメータ
annotation String

addIncludeFilter

public void addIncludeFilter (String filter)

含めるテストのフィルタを追加します。

パラメータ
filter String

clearExcludeAnnotations

public void clearExcludeAnnotations ()

現在トラッキングされている除外アノテーションをすべて削除します。

clearExcludeFilters

public void clearExcludeFilters ()

現在トラッキングされている除外フィルタをすべて削除します。

clearIncludeAnnotations

public void clearIncludeAnnotations ()

現在トラッキングされているインクルード アノテーションをすべて削除します。

clearIncludeFilters

public void clearIncludeFilters ()

現在トラッキングされているすべての除外フィルタを削除します。

countTestCases

public int countTestCases ()

テストの一部であるすべてのクラスのテストケースの数を返します

戻り値
int

getAbi

public IAbi getAbi ()

戻り値
IAbi

getClassNames

public Set<String> getClassNames ()

戻り値
Set<String>

getDevice

public ITestDevice getDevice ()

テスト対象デバイスを取得します。

戻り値
ITestDevice ITestDevice

getExcludeAnnotations

public Set<String> getExcludeAnnotations ()

除外するアノテーションの現在の Set を返します。

戻り値
Set<String>

getExcludeFilters

public Set<String> getExcludeFilters ()

除外フィルタの現在の Set を返します。

戻り値
Set<String>

getIncludeAnnotations

public Set<String> getIncludeAnnotations ()

含めるアノテーションの現在の Set を返します。

戻り値
Set<String>

getIncludeFilters

public Set<String> getIncludeFilters ()

インクルード フィルタの現在の Set を返します。

戻り値
Set<String>

getRuntimeHint

public long getRuntimeHint ()

テストの想定実行時間をミリ秒単位で返します。この時間は、シャード化された実行のロード バランシングに使用されます。

戻り値
long

run

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

テストを実行し、結果をリスナーに報告します。

パラメータ
testInfo TestInformation: テストの実行に役立つ情報を含む TestInformation オブジェクト。

listener ITestInvocationListener: テスト結果の ITestInvocationListener

例外
DeviceNotAvailableException

setAbi

public void setAbi (IAbi abi)

パラメータ
abi IAbi

setBuild

public void setBuild (IBuildInfo buildInfo)

パラメータ
buildInfo IBuildInfo

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

テスト収集モードを有効または無効にします

setConfiguration

public void setConfiguration (IConfiguration configuration)

使用中の IConfiguration を挿入します。

パラメータ
configuration IConfiguration

setDevice

public void setDevice (ITestDevice device)

テスト対象デバイスを挿入します。

パラメータ
device ITestDevice: 使用する ITestDevice

setOptionToLoadedObject

public static void setOptionToLoadedObject (Object testObj, 
                List<String> keyValueOptions)

デバイス ランナーが HostTest と同じ方法で set-option からオプションを設定するために使用するヘルパー。

パラメータ
testObj Object: オプションを受け取るオブジェクト。

keyValueOptions List: HostTest set-option で必要な形式で指定されたオプションのリスト。

setTestInformation

public void setTestInformation (TestInformation testInfo)

パラメータ
testInfo TestInformation

split

public Collection<IRemoteTest> split (Integer shardCount, 
                TestInformation testInfo)

テストクラスまたはメソッドごとに分割します。

パラメータ
shardCount Integer: 試行されたシャード数。

testInfo TestInformation: 親 TestInformation

戻り値
Collection<IRemoteTest> 個別に実行されるサブテストのコレクション。テストが現在シャード可能でない場合は null

保護されたメソッド

createHostTest

protected HostTest createHostTest (Class<?> classObj)

シャーディング時に HostTest インスタンスを作成するヘルパー。HostTest から子を返すようにオーバーライドします。

パラメータ
classObj Class

戻り値
HostTest

getBuild

protected IBuildInfo getBuild ()

HostTest が受信したビルド情報を取得します。

戻り値
IBuildInfo IBuildInfo

getClassLoader

protected ClassLoader getClassLoader ()

デフォルトのクラスローダを返します。

戻り値
ClassLoader

getClasses

protected final List<Class<?>> getClasses ()

戻り値
List<Class<?>>

例外
IllegalArgumentException

getJarFile

protected File getJarFile (String jarName, 
                TestInformation testInfo)

さまざまなユースケースでアーティファクトが通常配置される複数の場所を調べて、jar を見つけます。

パラメータ
jarName String

testInfo TestInformation

戻り値
File

例外
FileNotFoundException

hasJUnit4Annotation

protected boolean hasJUnit4Annotation (Class<?> classObj)

Junit4 アノテーション付きの Test クラスを処理しているかどうかを判断するヘルパー。

パラメータ
classObj Class

戻り値
boolean

loadObject

protected Object loadObject (Class<?> classObj)

クラス オブジェクトを読み込み、テスト情報(デバイス、ビルド)を設定します。

パラメータ
classObj Class

戻り値
Object

setClassName

protected void setClassName (String className)

実行するクラス名をクリアして設定します。

パラメータ
className String

setMethodName

protected void setMethodName (String methodName)

実行するメソッド名を設定します。

これは、テストクラスから特定のテストメソッドを実行するために使用されます。

パラメータ
methodName String

shouldTestRun

protected boolean shouldTestRun (AnnotatedElement annotatedElement)

アノテーションのある要素がフィルタを通過するかどうかを確認します。単体テスト用に公開されています。

戻り値
boolean テストを実行しない場合は false。