載入執行多個自動化測試指令碼

2021-08-16 08:09:23 字數 1179 閱讀 6791

import unittest

import re

import htmltestrunner

#載入測試檔案(針對方法一)

import testf1 #testf1表示testf1.py檔案

import testf2

#方法一:

#構造測試集

suit=unittest.testsuite()

suit.addtest(testf1.fangdongliqi("test_case1"))

suit.addtest(testf2.fangdongliqi("test_case2"))

if __name__=="__main__":

#執行測試

runner=unittest.texttestrunner()

runner.run(suit)

#方法二

test_dir=r'c:\users\administrator\desktop\python\web' #測試檔案位置

#test_dir=r'./' #指令碼所在位置,也可以用路徑表示,如:test_dir=r'c:\users\administrator\desktop\python\inte***ce' './'表示指令碼所在位置 './testfile/'表示與指令碼同級的資料夾

discover=unittest.defaulttestloader.discover(test_dir,pattern='testf1.py') #載入testf*.py的測試檔案,'*'表示匹配任意字元

if __name__=='__main__':

'''runner=unittest.texttestrunner()

runner.run(discover)

''''''

filename="testweb.html"

fp=open(filename,'wb')

'''with open('report.html','wb')as fp:

runner = htmltestrunner.htmltestrunner(stream=fp,title=u'web(version 1.0)測試報告',description=u'環境:windows 7 64位 瀏覽器:火狐 43.0.1')

runner.run(discover)

自動化測試中的測試執行自動化

自動化測試 這個術語的使用是如何對團隊深挖自動化益處產生束縛作用的,richard bradshaw 在agile testing days 2015上對此進行了 分析。infoq有幸採訪到了bradshaw,就測試和檢查的不同之處以及為什麼兩者都很重要 自動化能怎樣支援測試 自動化框架的使用以及為...

自動化測試中的測試執行自動化

自動化測試 這個術語的使用是如何對團隊深挖自動化益處產生束縛作用的,richard bradshaw 在agile testing days 2015上對此進行了 分析。infoq有幸採訪到了bradshaw,就測試和檢查的不同之處以及為什麼兩者都很重要 自動化能怎樣支援測試 自動化框架的使用以及為...

自動化測試執行指令碼(python)

自動化測試指令碼,以qq空間為例 賬號 密碼 使用者名稱根據實際情況填寫 1 寫測試用例 import unittest from selenium import webdriver import time 建立測試類 繼承unittest.testcase class testspace unit...