Update domain name to kpe.io
[xlunit.git] / textui.lisp
1 ;;;; -*- Mode: LISP; Syntax: ANSI-Common-Lisp; Base: 10 -*-
2 ;;;; *************************************************************************
3 ;;;; FILE IDENTIFICATION
4 ;;;;
5 ;;;; ID:      $Id$
6 ;;;; Purpose: Text UI for Test Runner
7 ;;;;
8 ;;;; *************************************************************************
9
10 (in-package #:xlunit)
11
12 ;;; Test Runners
13
14 (defclass textui-test-runner (test-listener)
15   ((ostream :initform nil :accessor ostream :initarg :ostream))
16   (:default-initargs :ostream *standard-output*))
17
18 (defmethod add-error ((ob textui-test-runner) test-case condition)
19   (declare (ignore test-case condition))
20   (format (ostream ob) "E"))
21
22 (defmethod add-failure ((ob textui-test-runner) test-case condition)
23   (declare (ignore test-case condition))
24   (format (ostream ob) "F"))
25
26 (defmethod start-test ((ob textui-test-runner) test-case)
27   (declare (ignore test-case))
28   (format (ostream ob) "."))
29
30
31 (defmethod textui-test-run ((ob test))
32   (let ((test-runner (make-instance 'textui-test-runner))
33         (result (make-instance 'test-results))
34         (start-time (get-internal-real-time)))
35     (add-listener result test-runner)
36     (run-on-test-results ob result)
37     (print-results test-runner result
38                    (/ (- (get-internal-real-time) start-time)
39                       internal-time-units-per-second))
40     result))