設備測試用例
public class DeviceTestCase
extends MetricTestCase
implements IDeviceTest , IRemoteTest , ITestCollector , ITestFilterReceiver , ITestAnnotationFilterReceiver
java.lang.Object | ||||
↳ | junit.framework.Assert | |||
↳ | junit.framework.TestCase | |||
↳ | com.android.tradefed.testtype.MetricTestCase | |||
↳ | com.android.tradefed.testtype.DeviceTestCase |
提供IRemoteTest
和IDeviceTest
服務的 Helper JUnit 測試用例。
如果您想實施遵循定義測試的 JUnit 模式的測試,並且仍然完全支持其他 tradefed 功能(例如Option
s),這將很有用
概括
領域 | |
---|---|
protected | mExcludeAnnotation 要運行的測試的排除註釋 |
protected | mExcludeFilters 要運行的測試名稱的排除過濾器 |
protected | mIncludeAnnotation 要運行的測試的包含註釋 |
protected | mIncludeFilters 要運行的測試名稱的包含過濾器 |
公共構造函數 | |
---|---|
DeviceTestCase () | |
DeviceTestCase (String name) |
公共方法 | |
---|---|
void | addAllExcludeAnnotation ( notAnnotations) addAllExcludeAnnotation ( notAnnotations) 添加一個 |
void | addAllExcludeFilters ( filters) addAllExcludeFilters ( filters) 添加要排除的測試的過濾器的 |
void | addAllIncludeAnnotation ( annotations) addAllIncludeAnnotation ( annotations) 添加一個 |
void | addAllIncludeFilters ( filters) addAllIncludeFilters ( filters) 添加要包含哪些測試的過濾器的 |
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) 注入被測設備。 |
領域
mExclude註解
protectedmExcludeAnnotation
要運行的測試的排除註釋
mExcludeFilters
protectedmExcludeFilters
要運行的測試名稱的排除過濾器
mIncludeAnnotation
protectedmIncludeAnnotation
要運行的測試的包含註釋
mIncludeFilters
protectedmIncludeFilters
要運行的測試名稱的包含過濾器
公共構造函數
設備測試用例
public DeviceTestCase ()
設備測試用例
public DeviceTestCase (String name)
參數 | |
---|---|
name | String |
公共方法
添加所有排除註釋
public void addAllExcludeAnnotation (notAnnotations)
添加一個ERROR(/Set)
註釋以排除是否測試是否用它標記。
參數 | |
---|---|
notAnnotations |
addAllIncludeAnnotation
public void addAllIncludeAnnotation (annotations)
添加一個ERROR(/Set)
註釋以包含是否測試是否用它標記。
參數 | |
---|---|
annotations |
添加排除註解
public void addExcludeAnnotation (String notAnnotation)
添加註釋以排除是否測試是否用它標記。
參數 | |
---|---|
notAnnotation | String |
添加排除過濾器
public void addExcludeFilter (String filter)
添加要排除哪些測試的過濾器。
參數 | |
---|---|
filter | String |
添加包含註解
public void addIncludeAnnotation (String annotation)
添加一個註釋以包含如果一個測試是否用它標記。
參數 | |
---|---|
annotation | String |
添加包含過濾器
public void addIncludeFilter (String filter)
添加要包含哪些測試的過濾器。
參數 | |
---|---|
filter | String |
清除排除註解
public void clearExcludeAnnotations ()
刪除當前跟踪的所有排除註釋。
清除排除過濾器
public void clearExcludeFilters ()
刪除當前跟踪的所有排除過濾器。
clearIncludeAnnotations
public void clearIncludeAnnotations ()
刪除當前跟踪的所有包含註釋。
清除包含過濾器
public void clearIncludeFilters ()
刪除當前跟踪的所有包含過濾器。
計數測試用例
public int countTestCases ()
退貨 | |
---|---|
int |
跑步
public void run (TestResult result)
如果要運行的測試方法為空,則覆蓋父方法以運行所有測試方法。
JUnit 框架僅支持通過將其包裝在 TestSuite 中來運行 TestCase 中的所有測試。不幸的是,使用這種機制,調用者無法控制他們自己的測試用例的生命週期,這使得無法執行諸如讓 tradefed 配置框架將選項注入測試用例之類的事情。參數 | |
---|---|
result | TestResult |
跑步
public void run (TestInformation testInfo, ITestInvocationListener listener)
運行測試,並將結果報告給偵聽器。
參數 | |
---|---|
testInfo | TestInformation :包含運行測試的有用信息的TestInformation 對象。 |
listener | ITestInvocationListener : 測試結果的ITestInvocationListener |
投擲 | |
---|---|
DeviceNotAvailableException |
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或禁用測試收集模式