本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
查看 IDT 测试结果和日志
本节介绍了 IDT 生成控制台日志和测试报告的格式。
控制台消息格式
Amazon IoT Device Tester使用标准格式在启动测试套件时将消息打印到控制台。以下摘录显示了 IDT 生成的控制台消息的示例。
[INFO] [2000-01-02 03:04:05]: Using suite: MyTestSuite_1.0.0 executionId=9a52f362-1227-11eb-86c9-8c8590419f30
大多数控制台消息由以下字段组成:
time
-
所记录事件的完整 ISO 8601 时间戳。
level
-
所记录事件的消息级别。通常,记录的消息级别是
info
warn
、或之一error
。如果 IDT 遇到导致其提前退出的预期事件,则会panic
发出fatal
或消息。 msg
-
记录的消息。
executionId
-
当前 IDT 进程的唯一 ID 字符串。此 ID 用于区分各个 IDT 运行。
从测试套件生成的控制台消息提供有关被测设备以及 IDT 运行的测试套件、测试组和测试用例的更多信息。以下摘录显示了从测试套件生成的控制台消息的示例。
[INFO] [2000-01-02 03:04:05]: Hello world! suiteId=MyTestSuitegroupId=myTestGroup testCaseId=myTestCase deviceId=my-deviceexecutionId=9a52f362-1227-11eb-86c9-8c8590419f30
控制台消息的测试套件特定部分包含以下字段:
suiteId
-
当前正在运行的测试套件的名称。
groupId
-
当前正在运行的测试组的 ID。
testCaseId
-
当前正在运行的测试用例的 ID。
deviceId
-
当前测试用例正在使用的被测设备的 ID。
测试摘要包含有关测试套件、运行的每个组的测试结果以及生成的日志和报告文件位置的信息。以下示例显示了测试摘要消息。
========== Test Summary ========== Execution Time: 5m00s Tests Completed: 4 Tests Passed: 3 Tests Failed: 1 Tests Skipped: 0 ---------------------------------- Test Groups: GroupA: PASSED GroupB: FAILED ---------------------------------- Failed Tests: Group Name: GroupB Test Name: TestB1 Reason: Something bad happened ---------------------------------- Path to Amazon IoT Device Tester Report: /path/to/awsiotdevicetester_report.xml Path to Test Execution Logs: /path/to/logs Path to Aggregated JUnit Report: /path/to/MyTestSuite_Report.xml
Amazon IoT Device Tester报告架构
awsiotdevicetester_report.xml
是一份包含以下信息的已签名报告:
-
IDT 版本。
-
测试套件版本。
-
用于签署报告的报告签名和密钥。
-
device.json
文件中指定的设备 SKU 和设备池名称。 -
经过测试的产品版本和设备功能。
-
测试结果的摘要汇总。此信息与
文件中包含的信息相同。suite-name
_report.xml
<apnreport> <awsiotdevicetesterversion>
idt-version
</awsiotdevicetesterversion> <testsuiteversion>test-suite-version
</testsuiteversion> <signature>signature
</signature> <keyname>keyname
</keyname> <session> <testsession>execution-id
</testsession> <starttime>start-time
</starttime> <endtime>end-time
</endtime> </session> <awsproduct> <name>product-name
</name> <version>product-version
</version> <features> <feature name="<feature-name>
" value="supported | not-supported | <feature-value>
" type="optional | required
"/> </features> </awsproduct> <device> <sku>device-sku
</sku> <name>device-name
</name> <features> <feature name="<feature-name>
" value="<feature-value>
"/> </features> <executionMethod>ssh | uart | docker
</executionMethod> </device> <devenvironment> <os name="<os-name>
"/> </devenvironment> <report><suite-name-report-contents>
</report> </apnreport>
awsiotdevicetester_report.xml
文件包含一个 <awsproduct>
标签,其中包含有关正测试的产品以及在运行测试套件后验证的产品功能的信息。
<awsproduct>
标签中使用的属性
name
-
所测试的产品的名称。
version
-
所测试的产品的版本。
features
-
验证的功能。标记为的功能
required
是测试套件验证设备所必需的功能。以下代码段演示了此信息在awsiotdevicetester_report.xml
文件中的显示方式。<feature name="ssh" value="supported" type="required"></feature>
标记为的
optional
功能不需要进行验证。以下代码段显示了可选功能。<feature name="hsi" value="supported" type="optional"></feature> <feature name="mqtt" value="not-supported" type="optional"></feature>
测试套件报告架构
报告采用 JUnit XML 格式suite-name
_Result.xml
<testsuites name="
<suite-name>
results" time="<run-duration>
" tests="<number-of-test>
" failures="<number-of-tests>
" skipped="<number-of-tests>
" errors="<number-of-tests>
" disabled="0"> <testsuite name="<test-group-id>
" package="" tests="<number-of-tests>
" failures="<number-of-tests>
" skipped="<number-of-tests>
" errors="<number-of-tests>
" disabled="0"> <!--success--> <testcase classname="<classname>
" name="<name>
" time="<run-duration>
"/> <!--failure--> <testcase classname="<classname>
" name="<name>
" time="<run-duration>
"> <failure type="<failure-type>
">reason
</failure> </testcase> <!--skipped--> <testcase classname="<classname>
" name="<name>
" time="<run-duration>
"> <skipped>reason
</skipped> </testcase> <!--error--> <testcase classname="<classname>
" name="<name>
" time="<run-duration>
"> <error>reason
</error> </testcase> </testsuite> </testsuites>
awsiotdevicetester_report.xml
或中的报告部分
列出了已运行的测试和结果。suite-name
_report.xml
第一个 XML 标签 <testsuites>
包含测试执行情况的摘要。例如:
<testsuites name="MyTestSuite results" time="2299" tests="28" failures="0" errors="0" disabled="0">
<testsuites>
标签中使用的属性
name
-
测试套件的名称。
time
-
运行测试套件所用的时间,以秒为单位。
tests
-
执行的测试数。
failures
-
已运行但未通过的测试数。
errors
-
IDT 无法执行的测试数。
disabled
-
此属性未使用,可以忽略。
如果出现测试失败或错误,则可以通过检查 <testsuites>
XML 标签来确定失败的测试。<testsuites>
标签内的 <testsuite>
XML 标签显示了测试组的测试结果摘要。例如:
<testsuite name="combination" package="" tests="1" failures="0" time="161" disabled="0" errors="0" skipped="0">
其格式与 <testsuites>
标签类似,但包含一个未使用并可忽略的 skipped
属性。在每个 <testsuite>
XML 标签内部,对于一个测试组,所执行的每个测试都有 <testcase>
标签。例如:
<testcase classname="Security Test" name="IP Change Tests" attempts="1"></testcase>
<testcase>
标签中使用的属性
name
-
测试的名称。
attempts
-
IDT 执行测试用例的次数。
当测试失败或出现错误时,将会在 <testcase>
标签中添加包含用于故障排除的信息的 <failure>
或 <error>
标签。例如:
<testcase classname="mcu.Full_MQTT" name="MQTT_TestCase" attempts="1"> <failure type="Failure">Reason for the test failure</failure> <error>Reason for the test execution error</error> </testcase>