private void HandleFailure(IFailureInformation failureInformation, IEnumerable <ITestCase> testCases, string methodMessage)
        {
            string classMessage;
            var    classExceptions = failureInformation.ConvertExceptions(out classMessage);

            var testClasses = from testCase in testCases
                              select testCase.TestMethod.TestClass.Class.Name;

            foreach (var typeName in testClasses.Distinct())
            {
                var classTask = context.GetRemoteTask(typeName);
                classTask.Failed(classExceptions, classMessage, methodMessage);

                // Call Finished. xunit2 will call Finished for us if the failure happens
                // during class execution, but it will already have been called if the error
                // happens in test collection cleanup. xunit1 will only call this method if
                // a catastrophic error happens (i.e. ambiguous methods). The 2.0 runner utility
                // wouldn't call finish in that case, and the 2.1 runner utility has already
                // called finish (and we've marked the class as finished successfully.
                // Fortunately, calling it again will update the status properly.
                classTask.Finished();
            }
        }