DeviceTestCase
public
class
DeviceTestCase
extends MetricTestCase
implements
IDeviceTest,
IRemoteTest,
ITestAnnotationFilterReceiver,
ITestCollector,
ITestFilterReceiver
java.lang.Object | ||||
↳ | junit.framework.Assert | |||
↳ | junit.framework.TestCase | |||
↳ | com.android.tradefed.testtype.MetricTestCase | |||
↳ | com.android.tradefed.testtype.DeviceTestCase |
提供 IRemoteTest
和 IDeviceTest
服務的輔助 JUnit 測試案例。
如果您想實作遵循 JUnit 模式的測試,並且仍能完整支援其他交易功能 (例如 Option
),這項功能就很實用。
摘要
欄位 | |
---|---|
protected
|
mExcludeAnnotation
要執行的測試的排除註解 |
protected
|
mExcludeFilters
要執行的測試名稱的排除篩選條件 |
protected
|
mIncludeAnnotation
要執行的測試的註解插入位置 |
protected
|
mIncludeFilters
要執行的測試名稱的納入篩選器 |
公用建構函式 | |
---|---|
DeviceTestCase()
|
|
DeviceTestCase(String name)
|
公用方法 | |
---|---|
void
|
addAllExcludeAnnotation(
新增 |
void
|
addAllExcludeFilters(
新增篩選器的 |
void
|
addAllIncludeAnnotation(
新增註解的 |
void
|
addAllIncludeFilters(
新增篩選器的 |
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()
|
ITestDevice
|
getDevice()
取得測試中的裝置。 |
|
getExcludeAnnotations()
傳回要排除的註解的目前 |
|
getExcludeFilters()
傳回排除篩選器的目前 |
|
getIncludeAnnotations()
傳回要納入的註解目前的 |
|
getIncludeFilters()
傳回目前的包含篩選器 |
void
|
run(TestResult result)
如果要執行的測試方法為空值,則覆寫父項方法以執行所有測試方法。 |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
執行測試,並將結果回報給監聽器。 |
void
|
setCollectTestsOnly(boolean shouldCollectTest)
啟用或停用測試收集模式 |
void
|
setDevice(ITestDevice device)
插入測試中的裝置。 |
欄位
mExcludeAnnotation
protectedmExcludeAnnotation
要執行的測試的排除註解
mExcludeFilters
protectedmExcludeFilters
要執行的測試名稱的排除篩選器
mIncludeAnnotation
protectedmIncludeAnnotation
要執行的測試的註解
mIncludeFilters
protectedmIncludeFilters
要執行的測試名稱的納入篩選器
公用建構函式
DeviceTestCase
public DeviceTestCase ()
DeviceTestCase
public DeviceTestCase (String name)
參數 | |
---|---|
name |
String |
公用方法
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 ()
刪除目前追蹤的所有納入註解。
clearIncludeFilters
public void clearIncludeFilters ()
刪除目前追蹤的所有包含篩選器。
countTestCases
public int countTestCases ()
傳回 | |
---|---|
int |
得分
public void run (TestResult result)
如果要執行的測試方法為空值,則覆寫父項方法以執行所有測試方法。
JUnit 架構僅支援在 TestSuite 中包裝 TestCase,以便執行 TestCase 中的所有測試。不幸的是,使用這個機制時,呼叫端無法控制自身測試案例的生命週期,因此無法執行像是讓 tradefed 設定架構將選項插入測試案例的操作。
參數 | |
---|---|
result |
TestResult |
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
執行測試,並將結果回報給監聽器。
參數 | |
---|---|
testInfo |
TestInformation :包含執行測試所需實用資訊的 TestInformation 物件。 |
listener |
ITestInvocationListener :測試結果的 ITestInvocationListener |
擲回 | |
---|---|
DeviceNotAvailableException |
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或停用測試收集模式
setDevice
public void setDevice (ITestDevice device)
插入測試中的裝置。
參數 | |
---|---|
device |
ITestDevice :要使用的 ITestDevice |