zoukankan      html  css  js  c++  java
  • 参数化测试应用及测试报告产出

    api_case运行所有的excel用例:

    处理警告:

     网页报告产出:

    run_all_case.py


    import os
    import unittest
    from utils import HTMLTestReportCN
    from utils.config_utils import local_config

    current_path = os.path.dirname(__file__)
    case_path = os.path.join( current_path,'..','testcases')
    result_path = os.path.join( current_path,'..',local_config.REPORT_PATH )

    def load_testcase():
    discover = unittest.defaultTestLoader.discover(start_dir=case_path,
    pattern='test_api_case.py',
    top_level_dir=case_path)
    all_case_suite = unittest.TestSuite()
    all_case_suite.addTest( discover )
    return all_case_suite

    result_dir = HTMLTestReportCN.ReportDirectory(result_path)
    result_dir.create_dir('P3P4接口自动化测试报告_')
    report_html_path = HTMLTestReportCN.GlobalMsg.get_value('report_path')
    report_html_obj = open( report_html_path,'wb' )
    runner = HTMLTestReportCN.HTMLTestRunner(stream=report_html_obj,
    title='P3P4接口自动化测试报告',
    description='数据驱动+关键字驱动测试框架学习',
    tester='P3P4')
    runner.run( load_testcase() )
    report_html_obj.close()


    test_api_case.py

    import os
    import unittest
    import warnings
    import paramunittest
    from utils.testcase_data_utils import TestcaseDataUtils
    from utils.requests_utils import RequestsUtils

    test_case_lists = TestcaseDataUtils().convert_testcase_data_to_list()

    @paramunittest.parametrized(
    *test_case_lists
    )
    class TestApiCase(paramunittest.ParametrizedTestCase):
    def setUp(self) -> None:
    warnings.simplefilter('ignore',ResourceWarning)
    def setParameters(self, case_id, case_step):
    self.case_id = case_id,
    self.case_step = case_step
    def test_api_case(self):
    self._testMethodName = self.case_step[0].get('测试用例编号')
    self._testMethodDoc = self.case_step[0].get('测试用例名称')
    test_result = RequestsUtils().request_by_step(self.case_step)
    self.assertTrue( test_result['check_result'] )

    if __name__=='__main__':
    unittest.main(verbosity=2)
    回忆滋润坚持
  • 相关阅读:
    SAS数据集推送到sql server 数据库 实现代码段
    windows server 2008通过任务计划程序定时访问网站
    把SAS批提交添加到鼠标右键
    SAS 报表输出一些新式控制
    iis ajax post 跨域问题解决
    sas infile 控制导入长度
    SAS infile 导入txt示例
    sas 批量处理缺少缺失值
    vue $router $route
    jsonp使用post方法
  • 原文地址:https://www.cnblogs.com/james5d/p/14127533.html
Copyright © 2011-2022 走看看