CONST

在自动化测试中,某些测试用例需要使用固定的数据。为了实现这一需求,我们需要引入定义常量的能力。通过定义常量,我们可以将固定的数据值赋予特定的常量,并在测试过程中使用这些常量来进行数据对比。这种方法使得测试用例的数据验证更加灵活、可维护性更高,确保了测试的一致性和准确性。

常量返回数据说明

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <rule code="DEMO_CONST" 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"},{"code":"0002","name":"崔胜利"}]}
  7. </bound>
  8. </action>
  9. <action code="getString" name="常量字符串" type="CONST" dataType="STRING">
  10. <bound>
  11. {"id":2,"orderCode":"123","orderQur":123,"stkId":"123","users":[{"code":"0001","name":"vinc"},{"code":"0002","name":"崔胜利"}]}
  12. </bound>
  13. </action>
  14. <action code="getNumber" name="常量数组" type="CONST" dataType="NUMBER">
  15. <bound>
  16. 123
  17. </bound>
  18. </action>
  19. <action code="getList" name="常量列表" type="CONST" complex="1" dataType="MAP">
  20. <bound>
  21. [{"id":1,"orderCode":"123","orderQur":123,"stkId":"123","users":[{"code":"0001","name":"vinc"},{"code":"0002","name":"崔胜利"}]},{"id":2,"orderCode":"123","orderQur":123,"stkId":"123","users":[{"code":"0001","name":"vinc"},{"code":"0002","name":"崔胜利"}]}]
  22. </bound>
  23. </action>
  24. </actions>
  25. <flows>
  26. <flow code="RU001G1">
  27. <execute code="stp1" name="获取常量对象" actionCode="getMap"/>
  28. <execute code="stp2" name="获取常量列表" actionCode="getList"/>
  29. <execute code="stp5" name="对比两个对象" actionCode="checkObj">
  30. <checkObj code="check1" name="判断对象" msg="对象不一样" cover="${stp1}" threshold="${stp2[1]}"/>
  31. </execute>
  32. <execute code="stp6" name="获取常量字符串" actionCode="getString"/>
  33. <execute code="stp7" name="对比两个对象" actionCode="checkObj">
  34. <checkObj code="check1" name="判断对象" msg="对象不一样" cover="${stp6}" threshold="${stp6}"/>
  35. </execute>
  36. <execute code="stp8" name="获取常量数字" actionCode="getNumber"/>
  37. </flow>
  38. </flows>
  39. </rule>