X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=example.lisp;h=44da45792d0444a989ba8a9145ec9a1eb85e248e;hb=318cda1a328e9d99af2270c73cb13262e485a1ff;hp=4f1fcb99a1a6d61b7754158eb7c8615b557c7129;hpb=95c39c23a9d9db5b42fbc784ac75557fb1eb1a60;p=xlunit.git diff --git a/example.lisp b/example.lisp index 4f1fcb9..44da457 100644 --- a/example.lisp +++ b/example.lisp @@ -3,30 +3,26 @@ ;;;; FILE IDENTIFICATION ;;;; ;;;; Name: example.lisp -;;;; Purpose: Example file for XLTest +;;;; Purpose: Example file for XLUnit ;;;; 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.3 2003/08/04 09:50:33 kevin Exp $ ;;;; ************************************************************************* -(defpackage #:xltest-example - (:use #:cl #:xltest) - (:export - #:math-test-suite)) +(defpackage #:xlunit-example + (:use #:cl #:xlunit) + (:export #:math-test-suite)) -(in-package #:xltest-example) +(in-package #:xlunit-example) ;;; First we define some basic fixtures that we are going to need to ;;; perform our tests. A fixture is a place to hold data we need ;;; 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)