Exemplo n.º 1
0
    def _process_test_results(self):
        test_results = []
        class_names = list(self.results_by_class_name.keys())
        class_names.sort()
        for class_name in class_names:
            message = "Class: {}".format(class_name)
            self.logger.info(message)
            method_names = list(self.results_by_class_name[class_name].keys())
            method_names.sort()
            for method_name in method_names:
                result = self.results_by_class_name[class_name][method_name]
                message = "\t{}: {}".format(result["Outcome"],
                                            result["MethodName"])
                duration = result["RunTime"]
                result["stats"] = self._get_stats_from_result(result)
                if duration:
                    message += " ({}s)".format(duration)
                self.logger.info(message)
                test_results.append({
                    "Children":
                    result.get("children", None),
                    "ClassName":
                    decode_to_unicode(class_name),
                    "Method":
                    decode_to_unicode(result["MethodName"]),
                    "Message":
                    decode_to_unicode(result["Message"]),
                    "Outcome":
                    decode_to_unicode(result["Outcome"]),
                    "StackTrace":
                    decode_to_unicode(result["StackTrace"]),
                    "Stats":
                    result.get("stats", None),
                    "TestTimestamp":
                    result.get("TestTimestamp", None),
                })
                if result["Outcome"] in ["Fail", "CompileFail"]:
                    self.logger.info("\tMessage: {}".format(result["Message"]))
                    self.logger.info("\tStackTrace: {}".format(
                        result["StackTrace"]))
        self.logger.info("-" * 80)
        self.logger.info(
            "Pass: {}  Retried: {}  Fail: {}  CompileFail: {}  Skip: {}".
            format(
                self.counts["Pass"],
                self.counts["Retriable"],
                self.counts["Fail"],
                self.counts["CompileFail"],
                self.counts["Skip"],
            ))
        self.logger.info("-" * 80)
        if self.counts["Fail"] or self.counts["CompileFail"]:
            self.logger.error("-" * 80)
            self.logger.error("Failing Tests")
            self.logger.error("-" * 80)
            counter = 0
            for result in test_results:
                if result["Outcome"] in ["Fail", "CompileFail"]:
                    counter += 1
                    self.logger.error("{}: {}.{} - {}".format(
                        counter,
                        result["ClassName"],
                        result["Method"],
                        result["Outcome"],
                    ))
                    self.logger.error("\tMessage: {}".format(
                        result["Message"]))
                    self.logger.error("\tStackTrace: {}".format(
                        result["StackTrace"]))

        return test_results
Exemplo n.º 2
0
 def _get_test_results(self):
     result = self.tooling.query_all(TEST_RESULT_QUERY.format(self.job_id))
     self.counts = {
         'Pass': 0,
         'Fail': 0,
         'CompileFail': 0,
         'Skip': 0,
     }
     for test_result in result['records']:
         class_name = self.classes_by_id[test_result['ApexClassId']]
         self.results_by_class_name[class_name][
             test_result['MethodName']] = test_result
         self.counts[test_result['Outcome']] += 1
     test_results = []
     class_names = self.results_by_class_name.keys()
     class_names.sort()
     for class_name in class_names:
         message = 'Class: {}'.format(class_name)
         self.logger.info(message)
         method_names = self.results_by_class_name[class_name].keys()
         method_names.sort()
         for method_name in method_names:
             result = self.results_by_class_name[class_name][method_name]
             message = '\t{}: {}'.format(result['Outcome'],
                                         result['MethodName'])
             duration = result['RunTime']
             result['stats'] = self._get_stats_from_result(result)
             if duration:
                 message += ' ({}s)'.format(duration)
             self.logger.info(message)
             test_results.append({
                 'Children':
                 result.get('children', None),
                 'ClassName':
                 decode_to_unicode(class_name),
                 'Method':
                 decode_to_unicode(result['MethodName']),
                 'Message':
                 decode_to_unicode(result['Message']),
                 'Outcome':
                 decode_to_unicode(result['Outcome']),
                 'StackTrace':
                 decode_to_unicode(result['StackTrace']),
                 'Stats':
                 result.get('stats', None),
                 'TestTimestamp':
                 result.get('TestTimestamp', None),
             })
             if result['Outcome'] in ['Fail', 'CompileFail']:
                 self.logger.info('\tMessage: {}'.format(result['Message']))
                 self.logger.info('\tStackTrace: {}'.format(
                     result['StackTrace']))
     self.logger.info('-' * 80)
     self.logger.info(
         'Pass: {}  Fail: {}  CompileFail: {}  Skip: {}'.format(
             self.counts['Pass'],
             self.counts['Fail'],
             self.counts['CompileFail'],
             self.counts['Skip'],
         ))
     self.logger.info('-' * 80)
     if self.counts['Fail'] or self.counts['CompileFail']:
         self.logger.error('-' * 80)
         self.logger.error('Failing Tests')
         self.logger.error('-' * 80)
         counter = 0
         for result in test_results:
             if result['Outcome'] not in ['Fail', 'CompileFail']:
                 continue
             counter += 1
             self.logger.error('{}: {}.{} - {}'.format(
                 counter, result['ClassName'], result['Method'],
                 result['Outcome']))
             self.logger.error('\tMessage: {}'.format(result['Message']))
             self.logger.error('\tStackTrace: {}'.format(
                 result['StackTrace']))
     return test_results
Exemplo n.º 3
0
 def _get_test_results(self):
     result = self.tooling.query_all(TEST_RESULT_QUERY.format(self.job_id))
     self.counts = {"Pass": 0, "Fail": 0, "CompileFail": 0, "Skip": 0}
     for test_result in result["records"]:
         class_name = self.classes_by_id[test_result["ApexClassId"]]
         self.results_by_class_name[class_name][
             test_result["MethodName"]
         ] = test_result
         self.counts[test_result["Outcome"]] += 1
     test_results = []
     class_names = list(self.results_by_class_name.keys())
     class_names.sort()
     for class_name in class_names:
         message = "Class: {}".format(class_name)
         self.logger.info(message)
         method_names = list(self.results_by_class_name[class_name].keys())
         method_names.sort()
         for method_name in method_names:
             result = self.results_by_class_name[class_name][method_name]
             message = "\t{}: {}".format(result["Outcome"], result["MethodName"])
             duration = result["RunTime"]
             result["stats"] = self._get_stats_from_result(result)
             if duration:
                 message += " ({}s)".format(duration)
             self.logger.info(message)
             test_results.append(
                 {
                     "Children": result.get("children", None),
                     "ClassName": decode_to_unicode(class_name),
                     "Method": decode_to_unicode(result["MethodName"]),
                     "Message": decode_to_unicode(result["Message"]),
                     "Outcome": decode_to_unicode(result["Outcome"]),
                     "StackTrace": decode_to_unicode(result["StackTrace"]),
                     "Stats": result.get("stats", None),
                     "TestTimestamp": result.get("TestTimestamp", None),
                 }
             )
             if result["Outcome"] in ["Fail", "CompileFail"]:
                 self.logger.info("\tMessage: {}".format(result["Message"]))
                 self.logger.info("\tStackTrace: {}".format(result["StackTrace"]))
     self.logger.info("-" * 80)
     self.logger.info(
         "Pass: {}  Fail: {}  CompileFail: {}  Skip: {}".format(
             self.counts["Pass"],
             self.counts["Fail"],
             self.counts["CompileFail"],
             self.counts["Skip"],
         )
     )
     self.logger.info("-" * 80)
     if self.counts["Fail"] or self.counts["CompileFail"]:
         self.logger.error("-" * 80)
         self.logger.error("Failing Tests")
         self.logger.error("-" * 80)
         counter = 0
         for result in test_results:
             if result["Outcome"] in ["Fail", "CompileFail"]:
                 counter += 1
                 self.logger.error(
                     "{}: {}.{} - {}".format(
                         counter,
                         result["ClassName"],
                         result["Method"],
                         result["Outcome"],
                     )
                 )
                 self.logger.error("\tMessage: {}".format(result["Message"]))
                 self.logger.error("\tStackTrace: {}".format(result["StackTrace"]))
     return test_results
Exemplo n.º 4
0
 def _get_test_results(self):
     result = self.tooling.query_all(TEST_RESULT_QUERY.format(self.job_id))
     self.counts = {"Pass": 0, "Fail": 0, "CompileFail": 0, "Skip": 0}
     for test_result in result["records"]:
         class_name = self.classes_by_id[test_result["ApexClassId"]]
         self.results_by_class_name[class_name][
             test_result["MethodName"]] = test_result
         self.counts[test_result["Outcome"]] += 1
     test_results = []
     class_names = self.results_by_class_name.keys()
     class_names.sort()
     for class_name in class_names:
         message = "Class: {}".format(class_name)
         self.logger.info(message)
         method_names = self.results_by_class_name[class_name].keys()
         method_names.sort()
         for method_name in method_names:
             result = self.results_by_class_name[class_name][method_name]
             message = "\t{}: {}".format(result["Outcome"],
                                         result["MethodName"])
             duration = result["RunTime"]
             result["stats"] = self._get_stats_from_result(result)
             if duration:
                 message += " ({}s)".format(duration)
             self.logger.info(message)
             test_results.append({
                 "Children":
                 result.get("children", None),
                 "ClassName":
                 decode_to_unicode(class_name),
                 "Method":
                 decode_to_unicode(result["MethodName"]),
                 "Message":
                 decode_to_unicode(result["Message"]),
                 "Outcome":
                 decode_to_unicode(result["Outcome"]),
                 "StackTrace":
                 decode_to_unicode(result["StackTrace"]),
                 "Stats":
                 result.get("stats", None),
                 "TestTimestamp":
                 result.get("TestTimestamp", None),
             })
             if result["Outcome"] in ["Fail", "CompileFail"]:
                 self.logger.info("\tMessage: {}".format(result["Message"]))
                 self.logger.info("\tStackTrace: {}".format(
                     result["StackTrace"]))
     self.logger.info("-" * 80)
     self.logger.info(
         "Pass: {}  Fail: {}  CompileFail: {}  Skip: {}".format(
             self.counts["Pass"],
             self.counts["Fail"],
             self.counts["CompileFail"],
             self.counts["Skip"],
         ))
     self.logger.info("-" * 80)
     if self.counts["Fail"] or self.counts["CompileFail"]:
         self.logger.error("-" * 80)
         self.logger.error("Failing Tests")
         self.logger.error("-" * 80)
         counter = 0
         for result in test_results:
             if result["Outcome"] not in ["Fail", "CompileFail"]:
                 continue
             counter += 1
             self.logger.error("{}: {}.{} - {}".format(
                 counter,
                 result["ClassName"],
                 result["Method"],
                 result["Outcome"],
             ))
             self.logger.error("\tMessage: {}".format(result["Message"]))
             self.logger.error("\tStackTrace: {}".format(
                 result["StackTrace"]))
     return test_results