JsonHttpTestResultReporter

public class JsonHttpTestResultReporter
extends CollectingTestListener

java.lang.Object
com.android.tradefed.result.CollectingTestListener
  com.android.tradefed.result.JsonHttpTestResultReporter


一种结果报告器,用于将测试指标结果和分支、设备信息编码为 JSON,并发布 到 HTTP 服务端点

摘要

公共构造函数

JsonHttpTestResultReporter()

公共方法

Map<String, String> getValidMetrics(Map<String, String> collectedMetrics)

仅添加数值指标,并跳过发布非数值指标。

void invocationEnded(long elapsedTime)

报告调用已终止,无论是成功终止还是因某些错误 情况而终止。

void invocationFailed(Throwable cause)

报告因某些错误情况而导致调用不完整。

void invocationStarted(IInvocationContext context)

报告测试调用已开始。

受保护的方法

ITestDevice getDevice(IInvocationContext context)
void parseAdditionalDeviceDetails(ITestDevice testDevice)

从测试设备检索设备名称、SDK 版本号和 build ID。

void postResults(JSONObject postData)

将数据发布到指定的 HTTP 端点

公共构造函数

JsonHttpTestResultReporter

public JsonHttpTestResultReporter ()

公共方法

getValidMetrics

public Map<String, String> getValidMetrics (Map<String, String> collectedMetrics)

仅添加数值指标,并跳过发布非数值指标。

参数
collectedMetrics Map:包含所有指标。

返回
Map<String, String> 仅数值指标。

invocationEnded

public void invocationEnded (long elapsedTime)

报告调用已终止,无论是成功终止还是因某些错误 情况而终止。

将由 TradeFederation 框架自动调用。

参数
elapsedTime long:调用的经过时间(以毫秒为单位)

invocationFailed

public void invocationFailed (Throwable cause)

报告因某些错误情况而导致调用不完整。

将由 TradeFederation 框架自动调用。

参数
cause Throwable:失败的 Throwable 原因

invocationStarted

public void invocationStarted (IInvocationContext context)

报告测试调用已开始。

将由 TradeFederation 框架自动调用。报告器需要替换 此方法,以支持多个设备报告。

参数
context IInvocationContext:有关调用的信息

受保护的方法

getDevice

protected ITestDevice getDevice (IInvocationContext context)

参数
context IInvocationContext

返回
ITestDevice

parseAdditionalDeviceDetails

protected void parseAdditionalDeviceDetails (ITestDevice testDevice)

从测试设备检索设备名称、SDK 版本号和 build ID。

参数
testDevice ITestDevice:从中收集信息的设备。

postResults

protected void postResults (JSONObject postData)

将数据发布到指定的 HTTP 端点

参数
postData JSONObject:要发布的数据