Beispiel #1
0
    def run(self):
        """
        run test
        :return:
        """
        try:
            suit = self.set_case_suite()
            if suit is not None:
                logger.info("********TEST START********")
                fp = open(resultPath, 'wb')
                runner = HTMLTestRunner.HTMLTestRunner(stream=fp, title='Test Report', description='Test Description')
                res=runner.run(suit)
                WeChatClient.sendmsg("测试结果","接口测试概述"+"\n成功数"+str(res.success_count)+"\n失败数"+str(res.failure_count)+"\n错误数"+str(res.error_count))

            else:
                logger.info("Have no case to test.")
        except Exception as ex:
            logger.error(str(ex))
        finally:
            logger.info("*********TEST END*********")
            fp.close()
            # send test report by email
            if on_off == 'on':
                self.email.send_email()
            elif on_off == 'off':
                logger.info("Doesn't send report email to developer.")
            else:
                logger.info("Unknow state.")
Beispiel #2
0
    def tearDown(self):
        """

        :return:
        """
        try:
            # self.log.build_case_line(self.case_name, str(self.return_json.status_code), str(self.info['result']),self.time)
            WeChatClient.sendmsg("DCCJ-退款用例","\nDCCJ-退款用例"+"\n用例名:"+self.case_name+"\n响应时间(ms):"+str(self.time))
        except KeyError:
            # self.log.build_case_line(self.case_name, str(self.return_json.status_code), str(self.info['message']),self.time)
            WeChatClient.sendmsg("DCCJ-退款用例","\nDCCJ-退款用例"+"\n用例名:"+self.case_name+"\n响应时间(ms):"+str(self.time))
        print("测试结束,输出log完结\n\n")
Beispiel #3
0
    def tearDown(self):
        """

        :return:
        """
        try:
            WeChatClient.sendmsg(
                "DCCJ-好美意下单用例", "\nDCCJ-好美意下单用例" + "\n用例名:" + self.case_name +
                "\n响应时间(ms):" + str(self.time))
        except KeyError:
            WeChatClient.sendmsg(
                "DCCJ-好美意下单用例", "\nDCCJ-好美意下单用例" + "\n用例名:" + self.case_name +
                "\n响应时间(ms):" + str(self.time))
        print("测试结束,输出log完结\n\n")