IsolatedHostTest

public class IsolatedHostTest
extends Object implements IBuildReceiver, IConfigurationReceiver, IRemoteTest, IShardableTest, ITestAnnotationFilterReceiver, ITestCollector, ITestFilterReceiver

java.lang.Object
   ↳ com.android.tradefed.testtype.IsolatedHostTest


實作 TradeFed 執行器,使用子程序在低依附元件環境中執行測試,而不是在主要程序中執行。

這個執行器會假設所有設定的 JAR 都在同一個測試目錄中,並在該目錄中啟動子程序。因為它必須為子程序選擇工作目錄,而許多測試都會受益於該目錄是測試目錄,因此這是可用的最佳折衷方案。

摘要

公用建構函式

IsolatedHostTest()

公用方法

void addAllExcludeAnnotation( notAnnotations)

新增註解的 ERROR(/Set),如果測試標示了該註解,就會排除這些註解。

void addAllExcludeFilters( filters)

新增要排除的測試篩選器 ERROR(/Set)

void addAllIncludeAnnotation( annotations)

新增註解的 ERROR(/Set),以便在測試標記時納入。

void addAllIncludeFilters( filters)

新增要納入測試的篩選器 ERROR(/Set)

void addExcludeAnnotation(String notAnnotation)

如果測試標示了註解,則會新增註解來排除測試。

void addExcludeFilter(String filter)

新增要排除的測試篩選器。

void addIncludeAnnotation(String annotation)

新增註解,以便在測試標記時加入測試。

void addIncludeFilter(String filter)

新增要納入的測試篩選條件。

void clearExcludeAnnotations()

刪除目前追蹤的所有排除註解。

void clearExcludeFilters()

刪除目前追蹤的所有排除篩選器。

void clearIncludeAnnotations()

刪除目前追蹤的所有 include 註解。

void clearIncludeFilters()

刪除目前追蹤的所有包含篩選器。

String compileClassPath()

為子程序建立類別路徑,其中包含執行測試所需的 JAR 檔

compileCommandArgs(String classpath, File artifactsDir)

組裝指令引數,以執行子程序執行器。

void deleteTempFiles()
File getCoverageExecFile()
getExcludeAnnotations()

傳回要排除的註解目前 ERROR(/Set)

getExcludeFilters()

傳回排除篩選器的目前 ERROR(/Set)

getIncludeAnnotations()

傳回要加入的註解目前 ERROR(/Set)

getIncludeFilters()

傳回包含篩選器的目前 ERROR(/Set)

void run(TestInformation testInfo, ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setBuild(IBuildInfo build)

void setCollectTestsOnly(boolean shouldCollectTest)

啟用或停用測試收集模式

void setConfiguration(IConfiguration configuration)

注入使用的 IConfiguration

void setDebug(boolean debug)
split(int shardCount)

split() 的替代版本,也會提供嘗試執行的 shardCount。

void uploadTestArtifacts(File logDir, ITestInvocationListener listener)
boolean useRavenwoodResources()
boolean useRobolectricResources()

受保護的方法

String compileLdLibraryPathInner(String androidHostOut)

我們從單元測試呼叫這個版本,並直接傳遞 ANDROID_HOST_OUT。

File getJarFile(String jarName, TestInformation testInfo)

從 HostTest 複製過來,模擬其單元測試的運用。

void setServer(ServerSocket server)

公用建構函式

IsolatedHostTest

public IsolatedHostTest ()

公用方法

addAllExcludeAnnotation

public void addAllExcludeAnnotation ( notAnnotations)

如果測試標示了註解,則新增要排除的註解 ERROR(/Set)

參數
notAnnotations

addAllExcludeFilters

public void addAllExcludeFilters ( filters)

新增要排除的測試篩選器 ERROR(/Set)

參數
filters

addAllIncludeAnnotation

public void addAllIncludeAnnotation ( annotations)

新增 ERROR(/Set) 註解,以便在測試標示該註解時納入。

參數
annotations

addAllIncludeFilters

public void addAllIncludeFilters ( filters)

新增要納入測試的篩選器 ERROR(/Set)

參數
filters

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 ()

刪除目前追蹤的所有 include 註解。

clearIncludeFilters

public void clearIncludeFilters ()

刪除目前追蹤的所有包含篩選器。

compileClassPath

public String compileClassPath ()

為子程序建立類別路徑,其中包含執行測試所需的 JAR

傳回
String 以冒號分隔類別路徑的字串。

compileCommandArgs

public  compileCommandArgs (String classpath, 
                File artifactsDir)

組裝指令引數,以執行子程序執行器。

參數
classpath String

artifactsDir File

傳回

deleteTempFiles

public void deleteTempFiles ()

getCoverageExecFile

public File getCoverageExecFile ()

傳回
File

getExcludeAnnotations

public  getExcludeAnnotations ()

傳回要排除的註解目前 ERROR(/Set)

傳回

getExcludeFilters

public  getExcludeFilters ()

傳回排除篩選器的目前 ERROR(/Set)

傳回

getIncludeAnnotations

public  getIncludeAnnotations ()

傳回要納入的註解目前 ERROR(/Set)

傳回

getIncludeFilters

public  getIncludeFilters ()

傳回包含篩選器的目前 ERROR(/Set)

傳回

得分

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

執行測試,並向接聽程式回報結果。

參數
testInfo TestInformation:包含執行測試的實用資訊的 TestInformation 物件。

listener ITestInvocationListener:測試結果的 ITestInvocationListener

擲回
DeviceNotAvailableException

setBuild

public void setBuild (IBuildInfo build)

參數
build IBuildInfo

setCollectTestsOnly

public void setCollectTestsOnly (boolean shouldCollectTest)

啟用或停用測試收集模式

setConfiguration

public void setConfiguration (IConfiguration configuration)

插入使用的 IConfiguration

參數
configuration IConfiguration

setDebug

public void setDebug (boolean debug)

參數
debug boolean

拆分

public  split (int shardCount)

split() 的替代版本,也會提供嘗試執行的 shardCount。這項功能適用於有時無法任意決定的測試執行器。

參數
shardCount int:嘗試的 Shard 數量。

傳回
要個別執行的子測試集合,或測試目前無法分片時的 null

uploadTestArtifacts

public void uploadTestArtifacts (File logDir, 
                ITestInvocationListener listener)

參數
logDir File

listener ITestInvocationListener

useRavenwoodResources

public boolean useRavenwoodResources ()

傳回
boolean

useRobolectricResources

public boolean useRobolectricResources ()

傳回
boolean

受保護的方法

compileLdLibraryPathInner

protected String compileLdLibraryPathInner (String androidHostOut)

我們從單元測試呼叫這個版本,並直接傳遞 ANDROID_HOST_OUT。我們需要這個檔案,因為 Java 沒有設定環境變數的 API。

參數
androidHostOut String

傳回
String

getJarFile

protected File getJarFile (String jarName, 
                TestInformation testInfo)

從 HostTest 複製過來,模擬其單元測試。

檢查不同用途的構件通常所在的多個位置,找出 JAR 檔案。

參數
jarName String

testInfo TestInformation

傳回
File

setServer

protected void setServer (ServerSocket server)

參數
server ServerSocket