Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Stay organized with collections
Save and categorize content based on your preferences.
JsonHttpTestResultReporter
public
class
JsonHttpTestResultReporter
extends CollectingTestListener
A result reporter that encode test metrics results and branch, device info into JSON and POST
into an HTTP service endpoint
Summary
Public methods |
|
getValidMetrics( collectedMetrics)
Add only the numeric metrics and skip posting the non-numeric metrics.
|
void
|
invocationEnded(long elapsedTime)
Reports that the invocation has terminated, whether successfully or due to some error
condition.
|
void
|
invocationFailed(Throwable cause)
Reports an incomplete invocation due to some error condition.
|
void
|
invocationStarted(IInvocationContext context)
Reports the start of the test invocation.
|
Public constructors
JsonHttpTestResultReporter
public JsonHttpTestResultReporter ()
Public methods
getValidMetrics
public getValidMetrics ( collectedMetrics)
Add only the numeric metrics and skip posting the non-numeric metrics.
Parameters |
collectedMetrics |
: contains all the metrics. |
Returns |
|
only the numeric metrics. |
invocationEnded
public void invocationEnded (long elapsedTime)
Reports that the invocation has terminated, whether successfully or due to some error
condition.
Will be automatically called by the TradeFederation framework.
Parameters |
elapsedTime |
long : the elapsed time of the invocation in ms |
invocationFailed
public void invocationFailed (Throwable cause)
Reports an incomplete invocation due to some error condition.
Will be automatically called by the TradeFederation framework.
Parameters |
cause |
Throwable : the Throwable cause of the failure |
invocationStarted
public void invocationStarted (IInvocationContext context)
Reports the start of the test invocation.
Will be automatically called by the TradeFederation framework. Reporters need to override
this method to support multiple devices reporting.
Parameters |
context |
IInvocationContext : information about the invocation |
Protected methods
parseAdditionalDeviceDetails
protected void parseAdditionalDeviceDetails (ITestDevice testDevice)
Retrieves the device name, sdk version number and the build id from
the test device.
Parameters |
testDevice |
ITestDevice : device to collect the information from. |
postResults
protected void postResults (JSONObject postData)
Post data to the specified HTTP endpoint
Parameters |
postData |
JSONObject : data to be posted |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-07-19 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-07-19 UTC."],[],[],null,["# JsonHttpTestResultReporter\n==========================\n\n\n`\npublic\n\n\nclass\nJsonHttpTestResultReporter\n`\n\n\n`\n\n\n`\n\n`\n\nextends `[CollectingTestListener](../../../../../../reference/tradefed/com/android/tradefed/result/CollectingTestListener.html)`\n\n\n`\n\n`\n\n\n`\n\n|---|---|--------------------------------------------------------|\n| java.lang.Object |||\n| ↳ | [com.android.tradefed.result.CollectingTestListener](../../../../../../reference/tradefed/com/android/tradefed/result/CollectingTestListener.html) ||\n| | ↳ | com.android.tradefed.result.JsonHttpTestResultReporter |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA result reporter that encode test metrics results and branch, device info into JSON and POST\ninto an HTTP service endpoint\n\nSummary\n-------\n\n| ### Public constructors ||\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[JsonHttpTestResultReporter](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#JsonHttpTestResultReporter())`() ` |\n\n| ### Public methods ||\n|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` ` | ` `[getValidMetrics](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#getValidMetrics(\u003cany\u003e))`(` collectedMetrics) Add only the numeric metrics and skip posting the non-numeric metrics. |\n| ` void` | ` `[invocationEnded](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#invocationEnded(long))`(long elapsedTime) ` Reports that the invocation has terminated, whether successfully or due to some error condition. |\n| ` void` | ` `[invocationFailed](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#invocationFailed(java.lang.Throwable))`(Throwable cause) ` Reports an incomplete invocation due to some error condition. |\n| ` void` | ` `[invocationStarted](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#invocationStarted(com.android.tradefed.invoker.IInvocationContext))`(`[IInvocationContext](../../../../../../reference/tradefed/com/android/tradefed/invoker/IInvocationContext.html)` context) ` Reports the start of the test invocation. |\n\n| ### Protected methods ||\n|-----------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` `[ITestDevice](../../../../../../reference/tradefed/com/android/tradefed/device/ITestDevice.html) | ` `[getDevice](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#getDevice(com.android.tradefed.invoker.IInvocationContext))`(`[IInvocationContext](../../../../../../reference/tradefed/com/android/tradefed/invoker/IInvocationContext.html)` context) ` |\n| ` void` | ` `[parseAdditionalDeviceDetails](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#parseAdditionalDeviceDetails(com.android.tradefed.device.ITestDevice))`(`[ITestDevice](../../../../../../reference/tradefed/com/android/tradefed/device/ITestDevice.html)` testDevice) ` Retrieves the device name, sdk version number and the build id from the test device. |\n| ` void` | ` `[postResults](../../../../../../reference/tradefed/com/android/tradefed/result/JsonHttpTestResultReporter.html#postResults(org.json.JSONObject))`(JSONObject postData) ` Post data to the specified HTTP endpoint |\n\nPublic constructors\n-------------------\n\n### JsonHttpTestResultReporter\n\n```\npublic JsonHttpTestResultReporter ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### getValidMetrics\n\n```\npublic getValidMetrics ( collectedMetrics)\n```\n\nAdd only the numeric metrics and skip posting the non-numeric metrics.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------------|------------------------------------|\n| `collectedMetrics` | : contains all the metrics. \u003cbr /\u003e |\n\n| Returns ||\n|---|----------------------------------|\n| | only the numeric metrics. \u003cbr /\u003e |\n\n### invocationEnded\n\n```\npublic void invocationEnded (long elapsedTime)\n```\n\nReports that the invocation has terminated, whether successfully or due to some error\ncondition.\n\n\u003cbr /\u003e\n\nWill be automatically called by the TradeFederation framework.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------------|---------------------------------------------------------|\n| `elapsedTime` | `long`: the elapsed time of the invocation in ms \u003cbr /\u003e |\n\n### invocationFailed\n\n```\npublic void invocationFailed (Throwable cause)\n```\n\nReports an incomplete invocation due to some error condition.\n\n\u003cbr /\u003e\n\nWill be automatically called by the TradeFederation framework.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|---------|-------------------------------------------------------------------------------------------------------------------------|\n| `cause` | `Throwable`: the [Throwable](../../../../../../reference/tradefed/java/lang/Throwable.html) cause of the failure \u003cbr /\u003e |\n\n### invocationStarted\n\n```\npublic void invocationStarted (IInvocationContext context)\n```\n\nReports the start of the test invocation.\n\nWill be automatically called by the TradeFederation framework. Reporters need to override\nthis method to support multiple devices reporting.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|---------------------------------------------------------------|\n| `context` | `IInvocationContext`: information about the invocation \u003cbr /\u003e |\n\nProtected methods\n-----------------\n\n### getDevice\n\n```\nprotected ITestDevice getDevice (IInvocationContext context)\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Parameters ||\n|-----------|-----------------------------|\n| `context` | `IInvocationContext` \u003cbr /\u003e |\n\n| Returns ||\n|--------------------------------------------------------------------------------------------------|--------|\n| [ITestDevice](../../../../../../reference/tradefed/com/android/tradefed/device/ITestDevice.html) | \u003cbr /\u003e |\n\n### parseAdditionalDeviceDetails\n\n```\nprotected void parseAdditionalDeviceDetails (ITestDevice testDevice)\n```\n\nRetrieves the device name, sdk version number and the build id from\nthe test device.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------------|---------------------------------------------------------------|\n| `testDevice` | `ITestDevice`: device to collect the information from. \u003cbr /\u003e |\n\n### postResults\n\n```\nprotected void postResults (JSONObject postData)\n```\n\nPost data to the specified HTTP endpoint\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|----------------------------------------|\n| `postData` | `JSONObject`: data to be posted \u003cbr /\u003e |"]]