public void TestFailed(string name, string type, string method, double duration, string output, string exceptionType, string message, string stackTrace)
        {
            var state = CurrentState;

            // We can only assume that it's stdout
            if (!string.IsNullOrEmpty(output))
            {
                server.TaskOutput(state.Task, output, TaskOutputType.STDOUT);
            }

            state.Duration = TimeSpan.FromSeconds(duration);

            state.Result = TaskResult.Exception;
            server.TaskException(state.Task, ExceptionConverter.ConvertExceptions(exceptionType, message, stackTrace, out state.Message));
        }
Beispiel #2
0
        // Called when a class failure is encountered (i.e., when a fixture from IUseFixture throws an
        // exception during construction or System.IDisposable.Dispose)
        // If the exception happens in the class (fixture) construtor, the child tests are not run, so
        // we need to mark them all as having failed
        public bool ClassFailed(string className, string exceptionType, string message, string stackTrace)
        {
            var methodMessage = string.Format("Class failed in {0}", className);

            // Make sure all of the child methods are marked as failures. If not, it's very easy to miss
            // exceptions - you have a bunch of passing tests, but the parent node is marked as a failure
            // (and not counted in the failing tests count). Failing all tests makes this apparent
            foreach (var task in taskProvider.GetDescendants(className))
            {
                server.TaskException(task, new[] { new TaskException(null, methodMessage, null) });
                server.TaskFinished(task, methodMessage, TaskResult.Error);
            }

            var state = CurrentState;

            state.Result = TaskResult.Exception;

            server.TaskException(state.Task, ExceptionConverter.ConvertExceptions(exceptionType, message, stackTrace, out state.Message));

            // Let's carry on running tests - I guess if it were a catastrophic error, we could chose to abort
            return(server.ShouldContinue);
        }