X-Git-Url: http://git.kpe.io/?p=xlunit.git;a=blobdiff_plain;f=example.lisp;h=ce53451183e8bab56b0d730865af147152ed2cf3;hp=4f1fcb99a1a6d61b7754158eb7c8615b557c7129;hb=c7bc011f355411986f238987a4f97c93f66818dc;hpb=95c39c23a9d9db5b42fbc784ac75557fb1eb1a60 diff --git a/example.lisp b/example.lisp index 4f1fcb9..ce53451 100644 --- a/example.lisp +++ b/example.lisp @@ -6,14 +6,12 @@ ;;;; Purpose: Example file for XLTest ;;;; Authors: Kevin Rosenberg and Craig Brozefsky ;;;; -;;;; Put in public domain by Kevin Rosenberg and onShore, Inc -;;;; $Id: example.lisp,v 1.1 2003/08/04 06:00:01 kevin Exp $ +;;;; $Id: example.lisp,v 1.2 2003/08/04 09:46:44 kevin Exp $ ;;;; ************************************************************************* (defpackage #:xltest-example (:use #:cl #:xltest) - (:export - #:math-test-suite)) + (:export #:math-test-suite)) (in-package #:xltest-example) @@ -22,11 +20,9 @@ ;;; during testing. Often there are many test cases that use the same ;;; data. Each of these test cases is an instance of a test-fixture. -(def-test-fixture math-fixture () - ((numbera - :accessor numbera) - (numberb - :accessor numberb)) +(defclass math-fixture (test-fixture) + ((numbera :accessor numbera) + (numberb :accessor numberb)) (:documentation "Test fixture for math testing")) ;;; Then we define a setup method for the fixture. This method is run @@ -73,36 +69,6 @@ (let ((result (- (numbera test) (numberb test)))) (assert-equal result 1))) - -;;; Now we can create a test-suite. A test-suite contains a group of -;;; test-cases (instances of test-fixture) and/or other test-suites. -;;; We can specify which tests are in a test-suite when we define the -;;; test-suite, or we can add them later. See the documentation and -;;; argument list for make-test-case for details on how to specify a -;;; test-case. - -(defparameter *manual-math-test-suite* - (make-test-suite - "Math Test Suite" - "Simple test suite for arithmetic operators." - '(("Addition Test" math-fixture - :test-thunk test-addition - :description "A simple test of the + operator") - ("Subtraction Test" math-fixture - :test-thunk test-subtraction - :description "A simple test of the - operator")))) - -(add-test (make-test-case "Subtraction Test 2" 'math-fixture - :test-thunk 'test-subtraction-2 - :description "A broken substraction test, should fail.") - *manual-math-test-suite*) - - -(defparameter *dynamic-math-test-suite* (make-test-suite 'math-fixture)) - ;;;; Finally we can run our test suite and see how it performs. -(report-result (run-test *manual-math-test-suite* - :handle-errors t) :verbose t) +(text-testrunner (make-test-suite 'math-fixture)) -(report-result (run-test *dynamic-math-test-suite* - :handle-errors t) :verbose nil)