zoukankan      html  css  js  c++  java
  • python模块学习之testlink (自动回写测试案例执行结果到testlink)

    安装

    pip install TestLink-API-Python-client  
    
    #!/usr/bin/env Python
    # -*- coding: utf-8 -*-
    '''
    Created on 2018年4月2日
    
    @author: Brenda
    '''
    
    import testlink
    from com.pingan.test.util.config import Config
    
    url = 'http://tm.paic.com.cn/testlink/lib/api/xmlrpc/v1/xmlrpc.php'
    key = 'a04a27098jnkkmeemme'
    test_project_name = 'NTS-CFB-AMS'  #testlink上的测试计划名称
       
    def set_testlink_result(case_id):
        ''' 
        @param case_id: 测试案例ID
        @return: 
        '''
        def _deco(func):
            def _func(self):
                    try:
                        func(self)                    
                        report_test_result(case_id, 'p')
                    except:
                        report_test_result(case_id, 'f')
                        raise
            return _func
        return _deco
    
    def report_test_result(test_case_id, test_result):
        '''
        @param test_case_id: 测试案例ID
        @param test_result: 测试结果 pass、failed
        @return: 
        '''
        test_case_id = str(test_case_id)
        test_case_id = test_case_id.replace(',', ',')
        case_id_list = test_case_id.split(',')
        #Config.set_test_plan_name('XXX版本回归测试')
        if Config.test_plan_name == None:
            pass
        else:
            for case_id in case_id_list:
                tlc = testlink.TestlinkAPIClient(url, key)
                test_plan = tlc.getTestPlanByName(test_project_name, Config.test_plan_name)
                
                if len(test_plan):
                    if isinstance(test_plan[0], dict):
                        test_plan_id = test_plan[0]['id']
    #                     print test_plan, str(test_plan_id) 
                        response = tlc.getBuildsForTestPlan(test_plan_id)
                        build_name = response[0]['name']
                        tlc.reportTCResult(testcaseid=case_id, testplanid=test_plan_id, buildname=build_name, status=test_result,notes='')
        #                 print res[0]['operation'], res[0]['message']
    
  • 相关阅读:
    控制流测试与条件测试
    12306的“短信公众号”到底是个啥?
    ISTQB名词辨析
    ISTQB TA
    启动Chrome时自动开启开发者模式
    LoadRunner Community Edition 12.60 无法获取Community License
    用言的活用声调变化规则
    ISTQB TTA大纲中提到的参考书目
    Java调用方法参数究竟是传值还是传址?
    Java中的Lambda表达式简介及应用
  • 原文地址:https://www.cnblogs.com/-brenda/p/8697411.html
Copyright © 2011-2022 走看看