CodeCoverageTestBase

public abstract class CodeCoverageTestBase
extends Object implements IDeviceTest, IRemoteTest, IBuildReceiver

java.lang.Object
   ↳ com.android.tradefed.testtype.CodeCoverageTestBase<T extends com.android.tradefed.testtype.CodeCoverageReportFormat>
Known Direct Subclasses
JackCodeCoverageTest An IRemoteTest which runs installed instrumentation test(s) and generates a code coverage report. 
JacocoCodeCoverageTest An IRemoteTest that generates a code coverage report by generating build.xml on the fly and executing the ant command. 


An abstract base class which runs installed instrumentation test(s) and collects execution data from each test that was run. Subclasses should implement the getReportFormat() method to convert the execution data into a human readable report and log it.

Summary

Nested classes

class CodeCoverageTestBase.CoverageCollectingListener

A ResultForwarder which collects coverage files. 

Public constructors

CodeCoverageTestBase()

Public methods

ITestDevice getDevice()

Get the device under test.

void run(ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

void setBuild(IBuildInfo buildInfo)

void setDevice(ITestDevice device)

Inject the device under test.

Protected methods

void cleanup()

Cleans up any resources allocated during a test run.

abstract File generateCoverageReport(Collection<File> executionData, T format)

Generates a human-readable coverage report from the given execution data.

abstract List<T> getReportFormat()

Returns the list of output formats to use when generating the coverage report.

Public constructors

CodeCoverageTestBase

CodeCoverageTestBase ()

Public methods

getDevice

ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

run

void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results
Throws
DeviceNotAvailableException

setBuild

void setBuild (IBuildInfo buildInfo)

Parameters
buildInfo IBuildInfo

setDevice

void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

Protected methods

cleanup

void cleanup ()

Cleans up any resources allocated during a test run. Called at the end of the run(ITestInvocationListener) after all coverage reports have been logged. This method is a stub, but can be overridden by subclasses as necessary.

generateCoverageReport

File generateCoverageReport (Collection<File> executionData, 
                T format)

Generates a human-readable coverage report from the given execution data. This method is called after all of the tests have finished running.

Parameters
executionData Collection: The execution data files collected while running the tests.
format T: The output format of the generated coverage report.
Returns
File
Throws
IOException

getReportFormat

List<T> getReportFormat ()

Returns the list of output formats to use when generating the coverage report.

Returns
List<T>