我用这样的示例值进行变量测试:
- testing:
- failed: "yes"
msg: "anothermessage"
- results:
- url: "ip:port"
json:
messages:
- message: "yepp"
severity: "ok"
failed: "yes"
msg: "ikan"
- failed: "no"
msg: "anothermessageyeay"
测试的值可能不同,并且有时密钥导致结构丢失,如示例所示。如何添加一些字符串的结果的关键,所以我可以Map它?
我希望输出是这样的:
- testing:
- results: "not exist"
failed: "yes"
msg: "anothermessage"
- results:
- url: "ip:port"
json:
messages:
- message: "yepp"
severity: "ok"
failed: "yes"
msg: "ikan"
- results: "not exist"
failed: "no"
msg: "anothermessageyeay"
1条答案
按热度按时间muk1a3rh1#
下面的表达式
也可以使用下面的模板
将默认属性 results 添加到字典
完整的测试剧本示例
给予