Guest User

Untitled

a guest
Jun 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. ### 获取变量的对象名称
  2.  
  3. from mymodule import MyObject
  4.  
  5. def return_string():
  6. return "Hello, world!"
  7.  
  8. def return_object(name):
  9. return MyObject(name)
  10. </nbsp>
  11.  
  12. *** Test Cases ***
  13. Returning one value
  14. ${string} = Return String
  15. Should Be Equal ${string} Hello, world!
  16. ${object} = Return Object Robot
  17. Should Be Equal ${object.name} Robot
  18.  
  19. ### 字符串和数字变量
  20. RobotFramework的案例数据缺省都是字符串,而`${}`中的内容是由Python解释执行的,所以`${1}`是数字1,`1`是字符串“1”。
  21.  
  22. String and Number
  23. ${str1} = Set Variable 1
  24. ${str2} = Set Variable 2
  25. ${num1} = Convert to Integer 1
  26. ${num2} = Convert to Integer 2
  27. Should Not Be Equal ${str1} ${num1}
  28. Should Not Be Equal 1 ${num1}
  29. Should Be Equal 1+1 ${num1}+1
  30. Should Not Be Equal 1+1 ${num2}
  31. Should Not Be Equal 1+1 ${str2}
  32. Should Be Equal ${num1+1} ${num2}
  33. Should Be Equal ${num1+1} ${2}
  34. Should Be Equal ${1+1} ${num2}
  35. Should Be Equal as Strings ${str1} ${num1}
  36.  
  37. ### 数组变量
  38.  
  39. *** Test Cases ***
  40. List Variables
  41. @{list} = Set Variable first value second value
  42. Should Be Equal @{list}[0] first value
  43. Should Be Equal ${list[0]} first value
  44. Should Be Equal @{list}[1] second value
  45. Should Be Equal ${list[1]} second value
  46. ${index} = Set Variable ${2}
  47. Should Be Equal @{list}[${index - 1}] second value
  48. Should Be Equal @{list}[${${index} - 1}] second value
  49. Should Be Equal ${list[2 - 1]} second value
  50. Should Be Equal ${list[${index} - 1]} second value
  51. Should Be Equal ${list[${index - 1}]} second value
Add Comment
Please, Sign In to add comment