X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=xptest-example.lisp;h=e96d0bf2bba5c5f4bd68033557ff6735cf8db669;hb=7f58715215c93f4ab9607eb940d8c0437c892252;hp=9700db211bb19b643b7fb4cc8bf5dabeb7846b3b;hpb=811f8c443ebbc85bab095bfd75db974f6dd52ae8;p=xptest.git diff --git a/xptest-example.lisp b/xptest-example.lisp index 9700db2..e96d0bf 100644 --- a/xptest-example.lisp +++ b/xptest-example.lisp @@ -4,7 +4,13 @@ ;;;; ;;;; Author: Craig Brozefsky ;;;; Put in public domain by onShore, Inc -(in-package :xp-test-example) + +(defpackage #:xp-test-example + (:use #:common-lisp #:xp-test) + (:export + #:math-test-suite)) + +(in-package #:xp-test-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 @@ -53,20 +59,20 @@ (let ((result (+ (numbera test) (numberb test)))) (unless (= result 5) (failure "Result was not 5 when adding ~A and ~A" - (numbera test) (numberb test))))) + (numbera test) (numberb test))))) (defmethod subtraction-test ((test math-fixture)) (let ((result (- (numberb test) (numbera test)))) (unless (= result 1) (failure "Result was not 1 when subtracting ~A ~A" - (numberb test) (numbera test))))) + (numberb test) (numbera test))))) ;;; This method is meant to signal a failure (defmethod subtraction-test2 ((test math-fixture)) (let ((result (- (numbera test) (numberb test)))) (unless (= result 1) (failure "Result was not 1 when subtracting ~A ~A" - (numbera test) (numberb test))))) + (numbera test) (numberb test))))) ;;; Now we can create a test-suite. A test-suite contains a group of @@ -77,19 +83,19 @@ ;;; test-case. (setf math-test-suite (make-test-suite - "Math Test Suite" - "Simple test suite for arithmetic operators." - ("Addition Test" 'math-fixture - :test-thunk 'addition-test - :description "A simple test of the + operator") - ("Subtraction Test" 'math-fixture - :test-thunk 'subtraction-test - :description "A simple test of the - operator"))) + "Math Test Suite" + "Simple test suite for arithmetic operators." + ("Addition Test" 'math-fixture + :test-thunk 'addition-test + :description "A simple test of the + operator") + ("Subtraction Test" 'math-fixture + :test-thunk 'subtraction-test + :description "A simple test of the - operator"))) (add-test (make-test-case "Substraction Test 2" 'math-fixture - :test-thunk 'subtraction-test2 - :description "A broken substraction test, should fail.") - math-test-suite) + :test-thunk 'subtraction-test2 + :description "A broken substraction test, should fail.") + math-test-suite) ;;;; Finally we can run our test suite and see how it performs. ;;;; (report-result (run-test math-test-suite) :verbose t)