r5449: *** empty log message ***
[xlunit.git] / result.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; Name:        result.lisp
6 ;;;; Purpose:     Result functions for XLUnit
7 ;;;; Authors:     Kevin Rosenberg
8 ;;;;
9 ;;;; $Id: result.lisp,v 1.1 2003/08/04 12:01:54 kevin Exp $
10 ;;;; *************************************************************************
11
12 (in-package #:xlunit)
13
14
15 (defclass test-result ()
16   ((test :initarg :test :reader result-test)
17    (count :initform 0 :accessor test-count)
18    (failures :initarg :failures :reader test-failures :initform nil)
19    (errors :initarg :errors :reader test-errors :initform nil))
20   (:documentation "The result of applying a test"))
21
22
23 (defun make-test-result ()
24   (make-instance 'test-result))
25
26 (defclass test-failure ()
27   ((failed-test :initarg :failed-test :reader failed-test)
28    (thrown-condition :initarg :thrown-condition :reader thrown-condition)))
29
30 (defmethod is-failure ((failure test-failure))
31   (typep (thrown-condition failure) 'test-failure-condition))
32
33 (defmethod print-object ((obj test-failure) stream)
34   (print-unreadable-object (obj stream :type t :identity nil)
35     (format stream "~A: " (failed-test obj))
36     (apply #'format stream 
37            (simple-condition-format-control (thrown-condition obj))
38            (simple-condition-format-arguments (thrown-condition obj)))))
39
40 (defmethod was-successful ((result test-result))
41   (and (null (test-failures result))
42        (null (test-errors result))))