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 模式定義測試的測試,但仍要完整支援其他 tradefed 功能 (例如 Options),這項功能就非常實用。
摘要
欄位 | |
|---|---|
protected
Set<String> |
mExcludeAnnotation
要執行的測試的排除註解 |
protected
Set<String> |
mExcludeFilters
要執行的測試名稱排除篩選器 |
protected
Set<String> |
mIncludeAnnotation
要執行的測試的註解。 |
protected
Set<String> |
mIncludeFilters
要執行的測試名稱的納入篩選器 |
公用建構函式 | |
|---|---|
DeviceTestCase()
|
|
DeviceTestCase(String name)
|
|
公用方法 | |
|---|---|
void
|
addAllExcludeAnnotation(Set<String> notAnnotations)
新增註解的 |
void
|
addAllExcludeFilters(Set<String> filters)
新增要排除的測試篩選器 |
void
|
addAllIncludeAnnotation(Set<String> annotations)
新增註解 |
void
|
addAllIncludeFilters(Set<String> filters)
新增要納入測試的篩選器 |
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()
刪除目前追蹤的所有納入篩選器。 |
int
|
countTestCases()
|
ITestDevice
|
getDevice()
取得受測裝置。 |
Set<String>
|
getExcludeAnnotations()
傳回要排除的註解目前 |
Set<String>
|
getExcludeFilters()
傳回排除篩選器的目前 |
Set<String>
|
getIncludeAnnotations()
傳回要納入的註解目前 |
Set<String>
|
getIncludeFilters()
傳回包含篩選器的目前 |
void
|
run(TestResult result)
如果要執行的測試方法為空值,請覆寫父項方法來執行所有測試方法。 |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
Runs the tests, and reports result to the listener. |
void
|
setCollectTestsOnly(boolean shouldCollectTest)
啟用或停用測試收集模式 |
void
|
setDevice(ITestDevice device)
注入受測裝置。 |
欄位
mExcludeAnnotation
protected Set<String> mExcludeAnnotation
要執行的測試排除註解
mExcludeFilters
protected Set<String> mExcludeFilters
要執行的測試名稱的排除篩選器
mIncludeAnnotation
protected Set<String> mIncludeAnnotation
要執行的測試的 include 註解
mIncludeFilters
protected Set<String> mIncludeFilters
要執行的測試名稱的納入篩選器
公用建構函式
DeviceTestCase
public DeviceTestCase ()
DeviceTestCase
public DeviceTestCase (String name)
| 參數 | |
|---|---|
name |
String |
公用方法
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 ()
刪除目前追蹤的所有 include 註解。
clearIncludeFilters
public void clearIncludeFilters ()
刪除目前追蹤的所有包含篩選器。
countTestCases
public int countTestCases ()
| 傳回 | |
|---|---|
int |
|
得分
public void run (TestResult result)
覆寫父項方法,在要執行的測試方法為空值時,執行所有測試方法。
JUnit 架構僅支援將 TestCase 包裝在 TestSuite 中,藉此執行 TestCase 中的所有測試。很遺憾,透過這項機制,呼叫端無法控管自身測試案例的生命週期,因此無法執行將選項插入測試案例等作業。
| 參數 | |
|---|---|
result |
TestResult |
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
執行測試,並向接聽程式回報結果。
| 參數 | |
|---|---|
testInfo |
TestInformation:包含執行測試實用資訊的 TestInformation 物件。 |
listener |
ITestInvocationListener:測試結果的 ITestInvocationListener |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或停用測試收集模式