Example #1
0
    def active(cls, suite=suite, report_name='index'):
        cls.stream()
        # cls.check()
        if os.path.exists(report()):
            shutil.rmtree(report())
        os.makedirs(report())
        os.makedirs(BI_protal.downloadpath)

        assert os.path.exists(BI_protal.driver_path), "chromedriver.exe  不存在"
        cls.start()
        HTMLReport.TestRunner(
            # report_file_name='BI_6.0.7_BeiJing_3_13_2日报周报',
            report_file_name=report_name,
            output_path=report('report'),
            title="BI-PORTAL 测试报告",
            description="描述测试项目相关信息",
            sequential_execution=True,
            lang='cn').run(suite())
Example #2
0
    def LoadAndRunTestCases(self):
        curTime = time.strftime("%Y%m%d%H%M%S", time.localtime())
        path = os.path.dirname(LOG_PATH + os.sep)
        name = 'testReport' + str(curTime)
        suite = unittest.TestSuite()
        runner = HTMLReport.TestRunner(name, path)

        for testSet in sorted(self.testSuitlist):
            url = self.testSuitlist[testSet]["url"]
            driverType = self.testSuitlist[testSet]["browserType"]
            print(driverType + "###" + url)

            d = None
            if driverType == "chrome":
                d = webdriver.Chrome(executable_path=CHROMEDRIVER)
            d.get(url)

            testCases = self.testSuitlist[testSet]["caseSet"]

            for case in testCases:
                print(case)

            d.get("about:")
Example #3
0
import time
import unittest
from test_suites.loginsuite import make_suite
from lib.HTMLTestRunner import HTMLTestRunner
from HTMLReport import HTMLReport

if __name__ == "__main__":
    # runtime = time.strftime("%Y-%m-%d-%H_%M_%S", time.localtime(time.time()))
    # reportname = "test_result_{}.html".format(runtime)
    # with open("reports/{}".format(reportname), 'wb') as f:
    #     runner = HTMLTestRunner(stream = f,
    #                             title='ECshop自动化登录测试报告',
    #                             description='CI版本测试结果',
    #                             verbosity=2
    #                             )
    #     runner.run(make_suite())

    HTMLReport.TestRunner(thread_count=3).run(make_suite())
Example #4
0
import unittest, os
from HTMLReport import HTMLReport
import time

# test_dir = './'  # 表示脚本当前路径
test_dir = os.path.dirname(os.getcwd()) + '/TestCase'  # 表示脚本当前路径
discovery = unittest.defaultTestLoader.discover(
    test_dir, pattern='test*.py')  # 匹配所有的test开头的.py文件

if __name__ == '__main__':
    # 测试用例执行器
    runner = HTMLReport.TestRunner(
        report_file_name='',  # 报告文件名,如果未赋值,将采用“test+时间戳”
        output_path='report',  # 保存文件夹名,默认“report”
        title='测试报告',  # 报告标题,默认“测试报告”
        description='无测试描述',  # 报告描述,默认“测试描述”
        thread_count=1,  # 并发线程数量(无序执行测试),默认数量 1
        thread_start_wait=0,  # 各线程启动延迟,默认 0 s
        sequential_execution=False,  # 是否按照套件添加(addTests)顺序执行,
        # 会等待一个addTests执行完成,再执行下一个,默认 False
        # 如果用例中存在 tearDownClass ,建议设置为True,
        # 否则 tearDownClass 将会在所有用例线程执行完后才会执行。
        # lang='en'
        lang='cn'  # 支持中文与英文,默认中文
    )
    # 执行测试用例套件
    runner.run(discovery)