【发布时间】:2018-01-05 15:00:02
【问题描述】:
有没有办法创建一个自定义格式化程序,其中显示通过的测试详细信息和一个除外列表?
这个问题的背景知识:我们正在尝试迁移到 RSpec 以进行硬件集成和系统测试。结果应该被推送到 CouchDB。我想要实现的是一个可以生成类似 YAML 输出的报告器,如下面的 sn-p:
{
"_id": "0006b6f0-c1bd-0135-1a98-455c37fe87f1",
"_rev": "1-9c9786b4b4681ee8493f182d4fc56ef9",
"sha1_repo": "68bb327b540097c10683830f0d82acbe54a47f03",
"steps": [
{
"result": "pass",
"description": "Time for Routing expect OK: 126 micro seconds (DLC and Data also OK)"
},
{
"result": "pass",
"description": "Time for Routing expect OK: 146 micro seconds (DLC and Data also OK)"
},
{
"result": "pass",
"description": "Time for Routing expect OK: 162 micro seconds (DLC and Data also OK)"
}
],
"time_start": "1513119108000",
"time_end": "1513119108000",
"result": "pass",
"testcase_title": "Komfort_TSG_HBFS_03_to_Komfort2_TSG_HBFS_03",
"testcase_id": "TC_1zu1_BAF_Komfort_TSG_HBFS_03_to_Komfort2_TSG_HBFS_03",
"hierarchy": [
"Hardware Integration Test",
"1 - Routing",
"1.1 Normal Routing",
"1zu1_BAF_TestCases",
"CAN_to_CAN"
]
}
如果测试失败,实现这一点没有问题,但我们还需要通过测试的结果,以便能够创建长期统计数据。
我可以覆盖 RSPec 的传递事件,但示例对象仅提供描述,没有更多信息。
class EliteReporter
RSpec::Core::Formatters.register self, :example_started, :example_passed, :example_failed, :example_finished
def example_passed(passed)
@output.printf "pass \n #{passed.example.description}"
end
end
提前感谢您的帮助。
【问题讨论】:
标签: ruby rspec integration-testing