From 8f5907772e2f42877ede975f104a061ee9a79526 Mon Sep 17 00:00:00 2001 From: "Thomas M. Hermann" Date: Thu, 22 Nov 2012 13:22:55 -0600 Subject: [PATCH] Update print-failure to work with result objects. --- lisp-unit.lisp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lisp-unit.lisp b/lisp-unit.lisp index 16ad025..d136332 100644 --- a/lisp-unit.lisp +++ b/lisp-unit.lisp @@ -513,8 +513,11 @@ assertion.") (name test-result) (length (pass test-result)) (length (fail test-result))) - (format t "~@[, ~S execution errors~].~2%" - (exerr test-result))) + (if (exerr test-result) + (format t ", and an execution error.") + (write-char #\.)) + (terpri) + (terpri)) (defun run-code (code) "Run the code to test the assertions." @@ -676,7 +679,7 @@ assertion.") (format t "~{~& | ~S => ~S~}~%" (funcall (extras result)))) (format t "~& |~%") - (class-name result)) + (class-name (class-of result))) (defmethod print-failure ((result assert-result)) (format t "~& | Expected ~{~S~^; ~} " (expected result)) @@ -698,6 +701,19 @@ assertion.") (format t "~<~%~:;but saw ~{~S~^; ~}~>" (actual result))) +(defmethod print-failure ((result test-result)) + "Print the failed assertions in the unit test." + (loop for fail in (fail result) do + (print-failure fail) + finally + (print-summary result))) + +(defmethod print-failure ((results test-results-db)) + "Print all of the failure tests." + (loop with db = (database results) + for test in (failed-tests results) do + (print-failure (gethash test db)))) + ;;; Print errors (defgeneric print-error (result) -- 2.11.4.GIT