public class

DeviceTestCase

extends TestCase
implements IDeviceTest IRemoteTest
java.lang.Object
   ↳ junit.framework.Assert
     ↳ junit.framework.TestCase
       ↳ com.android.tradefed.testtype.DeviceTestCase

Class Overview

Helper JUnit test case that provides the IRemoteTest and IDeviceTest services.

This is useful if you want to implement tests that follow the JUnit pattern of defining tests, and still have full support for other tradefed features such as Options

Summary

Public Constructors
DeviceTestCase()
DeviceTestCase(String name)
Public Methods
int countTestCases()
ITestDevice getDevice()
Get the device under test.
void run(ITestInvocationListener listener)
Runs the tests, and reports result to the listener.
void run(TestResult result)
Override parent method to run all test methods if test method to run is null.
void setDevice(ITestDevice device)
Inject the device under test.
[Expand]
Inherited Methods
From class junit.framework.TestCase
From class junit.framework.Assert
From class java.lang.Object
From interface com.android.tradefed.testtype.IDeviceTest
From interface com.android.tradefed.testtype.IRemoteTest
From interface junit.framework.Test

Public Constructors

public DeviceTestCase ()

public DeviceTestCase (String name)

Public Methods

public int countTestCases ()

public ITestDevice getDevice ()

Get the device under test.

Returns

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener the ITestInvocationListener of test results

public void run (TestResult result)

Override parent method to run all test methods if test method to run is null.

The JUnit framework only supports running all the tests in a TestCase by wrapping it in a TestSuite. Unfortunately with this mechanism callers can't control the lifecycle of their own test cases, which makes it impossible to do things like have the tradefed configuration framework inject options into a Test Case.

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device the ITestDevice to use