You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dubbocase.py 2.0 KiB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. """
  2. @author: lileilei
  3. @file: dubbocase.py
  4. @time: 2018/3/29 12:47
  5. """
  6. from Interface.dubbo_feng import DubboInterface
  7. from public.log import LOG, logger
  8. from public.panduan import assert_in
  9. from public.get_excel import datacel
  10. import os
  11. path = os.path.join(os.path.join(os.getcwd(), 'test_case_data'), 'dubbocase.xlsx')
  12. listid, listurl, listinterface, listmeth, listfobject, listparam, listassert = datacel(path)
  13. @logger('dubbo接口测试')
  14. def testdubbointerface():
  15. list_pass = 0
  16. list_fail = 0
  17. list_json = []
  18. listrelust = []
  19. list_weizhi = 0
  20. list_exption = 0
  21. for i in range(len(listid)):
  22. dubboapi = DubboInterface(url=listurl, interface=listinterface[i], method=listmeth[i], param=listfobject[i],
  23. **(eval(listparam[i])))
  24. dubboapireslu = dubboapi.getresult()
  25. if dubboapireslu['code'] == 0:
  26. LOG.info('inputdata> 参数:%s, url:%s ,返回:%s,预期:%s' % (listparam[i], listurl[i], dubboapireslu, listassert[i]))
  27. assert_re = assert_in(asserassert=listassert[i], returnjson=dubboapireslu)
  28. if assert_re['code'] == 0:
  29. list_json.append(dubboapireslu['result'])
  30. listrelust.append('pass')
  31. list_pass += 1
  32. elif assert_re['code'] == 1:
  33. list_fail += 1
  34. listrelust.append('fail')
  35. list_json.append(dubboapireslu['result'])
  36. elif assert_re['code'] == 2:
  37. list_exption += 1
  38. listrelust.append('exception')
  39. list_json.append(assert_re['result'])
  40. else:
  41. list_weizhi += 1
  42. listrelust.append('未知错误')
  43. list_json.append('未知错误')
  44. else:
  45. list_exption += 1
  46. listrelust.append('exception')
  47. list_json.append(dubboapireslu['result'])
  48. continue
  49. return listrelust, list_fail, list_pass, list_json, list_exption, list_weizhi

Introduction

生成接口测试报告

No topics