我正在使用我的Selenium Webdriver Python测试的HTMLTestRunner报告,URL:http://tungwaiyip.info/software/HTMLTestRunner.html
当测试运行完成时,我会将报告通过电子邮件发送给我们的开发和测试团队。 到达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'] = "cc4_server_dev@company.onmicrosoft.com"
msg['From'] = "system@company.com"
s = smtplib.SMTP()
s.connect(host=SMTP_SERVER)
s.sendmail(msg['From'], msg['To'], msg.as_string())
s.close()
我的HTMLRunner TestSUite代码片段是:
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
谢谢Riaz
答案 0 :(得分:0)
我建议您在某个网站上发布报告(或者可能是共享文件夹,然后发送),然后发送链接到它。另一种方法是压缩文件并发送。