(self)
{
              "result": {
                "testResults": {
                  "ChangePasswordControllerTest": {
                    "attributes": {
                      "type": "ApexTestQueueItem",
                      "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexTestQueueItem\/709o0000000DUTXAA4"
                    },
                    "ApexClassId": "01po0000001iVdWAAU",
                    "ApexClass": {
                      "attributes": {
                        "type": "ApexClass",
                        "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexClass\/01po0000001iVdWAAU"
                      },
                      "Name": "ChangePasswordControllerTest"
                    },
                    "Status": "Completed",
                    "ExtendedStatus": "(0\/1)",
                    "results": [
                      {
                        "attributes": {
                          "type": "ApexTestResult",
                          "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexTestResult\/07Mo0000002IOAdEAO"
                        },
                        "Outcome": "Fail",
                        "ApexClassId": "01po0000001iVdWAAU",
                        "ApexClass": {
                          "attributes": {
                            "type": "ApexClass",
                            "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexClass\/01po0000001iVdWAAU"
                          },
                          "Name": "ChangePasswordControllerTest"
                        },
                        "MethodName": "testChangePasswordController",
                        "Message": "System.AssertException: Assertion Failed",
                        "StackTrace": "Class.mm2.ChangePasswordControllerTest.testChangePasswordController: line 13, column 1",
                        "ApexLogId": "07Lo000000SpsbJEAR"
                      }
                    ]
                  }
                },
                "coverageResults": {
                  "classes": {
                    "ChangePasswordController": {
                      "coveredLines": [
                        5,
                        6,
                        7,
                        9,
                        10,
                        11,
                        14
                      ],
                      "uncoveredLines": [

                      ],
                      "totalLines": 7,
                      "percentCovered": 100
                    }
                  },
                  "triggers": {

                  }
                }
              },
              "success": true
            }
{
              "result": {
                "testResults": {
                  "ChangePasswordControllerTest": {
                    "attributes": {
                      "type": "ApexTestQueueItem",
                      "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexTestQueueItem\/709o0000000DUTXAA4"
                    },
                    "ApexClassId": "01po0000001iVdWAAU",
                    "ApexClass": {
                      "attributes": {
                        "type": "ApexClass",
                        "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexClass\/01po0000001iVdWAAU"
                      },
                      "Name": "ChangePasswordControllerTest"
                    },
                    "Status": "Completed",
                    "ExtendedStatus": "(0\/1)",
                    "results": [
                      {
                        "attributes": {
                          "type": "ApexTestResult",
                          "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexTestResult\/07Mo0000002IOAdEAO"
                        },
                        "Outcome": "Fail",
                        "ApexClassId": "01po0000001iVdWAAU",
                        "ApexClass": {
                          "attributes": {
                            "type": "ApexClass",
                            "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexClass\/01po0000001iVdWAAU"
                          },
                          "Name": "ChangePasswordControllerTest"
                        },
                        "MethodName": "testChangePasswordController",
                        "Message": "System.AssertException: Assertion Failed",
                        "StackTrace": "Class.mm2.ChangePasswordControllerTest.testChangePasswordController: line 13, column 1",
                        "ApexLogId": "07Lo000000SpsbJEAR"
                      }
                    ]
                  }
                },
                "coverageResults": {
                  "classes": {
                    "ChangePasswordController": {
                      "coveredLines": [
                        5,
                        6,
                        7,
                        9,
                        10,
                        11,
                        14
                      ],
                      "uncoveredLines": [
{ result : { testResults : { ChangePasswordControllerTest : { attributes : { type : ApexTestQueueItem url : \ / services \ / data \ / v32 . 0 \ / tooling \ / sobjects \ / ApexTestQueueItem \ / 709o0000000DUTXAA4 } ApexClassId : 01po0000001iVdWAAU ApexClass : { attributes : { type : ApexClass url : \ / services \ / data \ / v32 . 0 \ / tooling \ / sobjects \ / ApexClass \ / 01po0000001iVdWAAU } Name : ChangePasswordControllerTest } Status : Completed ExtendedStatus : ( 0 \ / 1 ) results : [ { attributes : { type : ApexTestResult url : \ / services \ / data \ / v32 . 0 \ / tooling \ / sobjects \ / ApexTestResult \ / 07Mo0000002IOAdEAO } Outcome : Fail ApexClassId : 01po0000001iVdWAAU ApexClass : { attributes : { type : ApexClass url : \ / services \ / data \ / v32 . 0 \ / tooling \ / sobjects \ / ApexClass \ / 01po0000001iVdWAAU } Name : ChangePasswordControllerTest } MethodName : testChangePasswordController Message : System . AssertException : Assertion Failed StackTrace : Class . mm2 . ChangePasswordControllerTest . testChangePasswordController : line 13 column 1 ApexLogId : 07Lo000000SpsbJEAR } ] } } coverageResults : { classes : { ChangePasswordController : { coveredLines : [ 5 6 7 9 10 11 14 ] uncoveredLines : [
def __handle_test_result(self):
        '''
            {
              "result": {
                "testResults": {
                  "ChangePasswordControllerTest": {
                    "attributes": {
                      "type": "ApexTestQueueItem",
                      "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexTestQueueItem\/709o0000000DUTXAA4"
                    },
                    "ApexClassId": "01po0000001iVdWAAU",
                    "ApexClass": {
                      "attributes": {
                        "type": "ApexClass",
                        "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexClass\/01po0000001iVdWAAU"
                      },
                      "Name": "ChangePasswordControllerTest"
                    },
                    "Status": "Completed",
                    "ExtendedStatus": "(0\/1)",
                    "results": [
                      {
                        "attributes": {
                          "type": "ApexTestResult",
                          "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexTestResult\/07Mo0000002IOAdEAO"
                        },
                        "Outcome": "Fail",
                        "ApexClassId": "01po0000001iVdWAAU",
                        "ApexClass": {
                          "attributes": {
                            "type": "ApexClass",
                            "url": "\/services\/data\/v32.0\/tooling\/sobjects\/ApexClass\/01po0000001iVdWAAU"
                          },
                          "Name": "ChangePasswordControllerTest"
                        },
                        "MethodName": "testChangePasswordController",
                        "Message": "System.AssertException: Assertion Failed",
                        "StackTrace": "Class.mm2.ChangePasswordControllerTest.testChangePasswordController: line 13, column 1",
                        "ApexLogId": "07Lo000000SpsbJEAR"
                      }
                    ]
                  }
                },
                "coverageResults": {
                  "classes": {
                    "ChangePasswordController": {
                      "coveredLines": [
                        5,
                        6,
                        7,
                        9,
                        10,
                        11,
                        14
                      ],
                      "uncoveredLines": [

                      ],
                      "totalLines": 7,
                      "percentCovered": 100
                    }
                  },
                  "triggers": {

                  }
                }
              },
              "success": true
            }
        '''
        msg = ''

        debug(self.response['result']['testResults'])

        for test_class_name in self.response['result']['testResults'].keys():

            debug(test_class_name)
            debug(self.response['result']['testResults'][test_class_name])

            test_result = self.response['result']['testResults'][test_class_name]
            tests_passed_vs_failed = test_result['ExtendedStatus']

            tests_passed_vs_failed = tests_passed_vs_failed.replace('(', '').replace(')','')
            if tests_passed_vs_failed.split('/')[0] != tests_passed_vs_failed.split('/')[1]:
                msg += '[TEST RESULT]: FAIL'
            else:
                msg += '[TEST RESULT]: PASS'

            msg += '\n\n' + test_class_name + ': ' + test_result['ExtendedStatus'] + ' Passed'

            for r in test_result['results']:
                msg += '\n\n METHOD RESULT \n'
                msg += "{0} : {1}".format(r['MethodName'], r['Outcome'])

                if "StackTrace" in r and r["StackTrace"] != None:
                    msg += "\n\n"
                    msg += " STACK TRACE "
                    msg += "\n"
                    msg += r["StackTrace"]

                if "Message" in r and r["Message"] != None:
                    msg += "\n\n"
                    msg += " MESSAGE "
                    msg += "\n"
                    msg += r["Message"]
                    msg += "\n"

        self.__print_to_panel(msg)
def __handle_test_result ( self ) : msg = '' debug ( self . response [ 'result' ] [ 'testResults' ] ) for test_class_name in self . response [ 'result' ] [ 'testResults' ] . keys ( ) : debug ( test_class_name ) debug ( self . response [ 'result' ] [ 'testResults' ] [ test_class_name ] ) test_result = self . response [ 'result' ] [ 'testResults' ] [ test_class_name ] tests_passed_vs_failed = test_result [ 'ExtendedStatus' ] tests_passed_vs_failed = tests_passed_vs_failed . replace ( '(' , '' ) . replace ( ')' , '' ) if tests_passed_vs_failed . split ( '/' ) [ 0 ] != tests_passed_vs_failed . split ( '/' ) [ 1 ] : msg += '[TEST RESULT]: FAIL' else : msg += '[TEST RESULT]: PASS' msg += '\n\n' + test_class_name + ': ' + test_result [ 'ExtendedStatus' ] + ' Passed' for r in test_result [ 'results' ] : msg += '\n\n METHOD RESULT \n' msg += "{0} : {1}" . format ( r [ 'MethodName' ] , r [ 'Outcome' ] ) if "StackTrace" in r and r [ "StackTrace" ] != None : msg += "\n\n" msg += " STACK TRACE " msg += "\n" msg += r [ "StackTrace" ] if "Message" in r and r [ "Message" ] != None : msg += "\n\n" msg += " MESSAGE " msg += "\n" msg += r [ "Message" ] msg += "\n" self . __print_to_panel ( msg )