CHECK_OBJ

对象对比的功能在自动化测试中支持多种数据格式,包括 XML、文本(Text)、HTML 和 JSON。这意味着您可以使用 checkObj 来比较和验证这些不同格式的数据对象。它提供了灵活的方式来检查和核实数据对象在不同格式中的一致性,以确保测试结果的准确性和可靠性。无论您处理的是 XML 文档、纯文本、HTML 页面还是 JSON checkObj 都可以帮助您轻松地进行对象值的比较和验证。

checkObj 已经是全局的配置,不需要单独定义 action

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <rule code="DEMO_CheckObj" name="对象比较" model="flow">
  3. <actions>
  4. <action code="getMap" name="常量MAP" type="CONST" dataType="MAP">
  5. <bound>
  6. {"id":2,"orderCode":"123","orderQur":123,"stkId":"123","users":{"code":"0001","name":"vinc"}}
  7. </bound>
  8. </action>
  9. <action code="getMap2" name="常量MAP" type="CONST" dataType="MAP">
  10. <bound>
  11. {"id":2,"orderCode":"123","orderQur":123,"stkId":"123","users":[{"code":"0001","name":"vinc"},{"code":"0002","name":"崔胜利"}]}
  12. </bound>
  13. </action>
  14. </actions>
  15. <flows>
  16. <flow code="RU001G1">
  17. <execute code="stp1" name="常量MAP" actionCode="getMap"/>
  18. <execute code="stp2" name="常量MAP2" actionCode="getMap2"/>
  19. <execute code="stp3" name="对比两个对象" actionCode="checkObj">
  20. <checkObj code="check1" name="判断对象" msg="对象不一样" cover="${stp1}" threshold="${stp2}"/>
  21. </execute>
  22. <execute code="stp4" name="对比两个对象" actionCode="checkObj">
  23. <checkObj code="check1" name="判断对象" msg="对象不一样" cover="${stp1}" threshold="${stp1}"/>
  24. </execute>
  25. </flow>
  26. </flows>
  27. </rule>