我使用了我的硒的webdriver的Python測試HTMLTestRunner報告,網址:http://tungwaiyip.info/software/HTMLTestRunner.html爲Python HTMLTestRunner報告是非常大的,需要一定的時間在Outlook中打開
當測試運行結束後,我通過電子郵件發送給我們的開發報告和測試團隊。 到達Outlook的電子郵件爲2MB,打開電子郵件需要一段時間。 我的測試套件中有59個測試用例。 有沒有一種方法可以縮短這個,所以它不需要時間打開電子郵件?
我發送電子郵件的代碼片段是:
def send_selenium_report():
fileToSend_part1 = r"E:\test_runners 2 edit project\selenium_regression_test_5_1_1\TestReport\ClearCore501_Automated_GUI_TestReport.html"
with open(fileToSend_part1, "rt") as f:
text = f.read()
msg = MIMEText(text, "html")
msg['Subject'] = "ClearCore 5_1_1 Automated GUI Test"
msg['to'] = "[email protected]"
msg['From'] = "[email protected]"
s = smtplib.SMTP()
s.connect(host=SMTP_SERVER)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.close()
我對HTMLRunner測試套件的代碼片段是:
import sys
import unittest
from HTMLTestRunner2 import HTMLTestRunner
from Utilities.HelperMethods import get_datetime_now
import os
import unittest
import Regression_TestCase.RegressionProjectEdit_TestCase
class Test_Suite(unittest.TestCase):
def test_main(self):
tests_regression = unittest.TestLoader().loadTestsFromTestCase(
Regression_TestCase.RegressionProjectEdit_TestCase.RegressionProject_TestCase_Project_Edit)
regression_tests = unittest.TestSuite([tests_regression])
def suite():
"""
Gather all the tests from this module in a test suite.
"""
test_suite = unittest.TestSuite()
test_suite.addTest(unittest.makeSuite(Regression_TestCase.RegressionProjectEdit_TestCase.RegressionProject_TestCase_Project_Edit))
return test_suite
mySuit = suite()
# output to a file
test_result_dir = os.path.join(
r"E:\\test_runners 2 edit project\\selenium_regression_test_5_1_1\\TestReport\\")
# open the report file
outfile = file(test_result_dir + "\ClearCore501_Automated_GUI_TestReport.html", "wb")
# configure HTMLTestRunner options
runner = HTMLTestRunner.HTMLTestRunner(stream=outfile,
title='Test Report',
description='Selenium - ClearCore 501 Regression edit project automated test')
# run the suite using HTMLTestRunner
runner.run(mySuit)
if __name__ == "__main__":
# unittest.main()
HTMLTestRunner.main()
我已經上傳報告文件到共享位置。這個鏈接是:http://www.filedropper.com/clearcore501automatedguitestreport
感謝,里亞茲
您是否嘗試自定義您的報告?可能是它包含過多的樣式,腳本,日誌輸出,註釋等? – olyv
它使用一個插件,我已經提到了上面的鏈接。我不知道如何定製它。我在想也許我可以使用BeautifulSoup API來提取通行證,在報告中失敗並使用它。 –