X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=example.lisp;h=4a89aec87074524355632b0c8024fff9d10b57e6;hb=6c233c812b0e160d80e613bb3dfcedc59514e3e9;hp=3fc9e3a2ce65a1cb3cd7c15a2291f29899bf87a0;hpb=53e193feda5d4cb757ef13d622fac03cf99178a2;p=xlunit.git diff --git a/example.lisp b/example.lisp index 3fc9e3a..4a89aec 100644 --- a/example.lisp +++ b/example.lisp @@ -2,7 +2,7 @@ ;;;; ************************************************************************* ;;;; FILE IDENTIFICATION ;;;; -;;;; ID: $Id: example.lisp,v 1.5 2003/08/04 16:13:58 kevin Exp $ +;;;; ID: $Id: example.lisp,v 1.7 2003/08/04 19:31:34 kevin Exp $ ;;;; Purpose: Example file for XLUnit ;;;; ;;;; ************************************************************************* @@ -13,48 +13,39 @@ (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 +;;; First we define some basic test-cases that we are going to need to +;;; perform our tests. A test-case 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-case. -(defclass math-fixture (test-case) +(defclass math-test-case (test-case) ((numbera :accessor numbera) (numberb :accessor numberb)) - (:documentation "Test fixture for math testing")) + (:documentation "Test test-case for math testing")) -;;; Then we define a set-up method for the fixture. This method is run -;;; prior to perfoming any test with an instance of this fixture. It +;;; Then we define a set-up method for the test-case. This method is run +;;; prior to perfoming any test with an instance of this test-case. It ;;; should perform all initialization needed, and assume that it is starting ;;; with a pristine environment, well to a point, use your head here. -(defmethod set-up ((fix math-fixture)) - (setf (numbera fix) 2) - (setf (numberb fix) 3)) +(defmethod set-up ((tcase math-test-case)) + (setf (numbera tcase) 2) + (setf (numberb tcase) 3)) -;;; Then we define a teardown method, which should return the instance -;;; to it's original form and reset the environment. In this case -;;; there is little for us to do since the fixture is quite static. -;;; In other cases we may need to clear some database tables, or -;;; otherwise get rid of state built up while perofmring the test. -;;; Here we just return T. -(defmethod tear-down ((fix math-fixture)) - t) - -(def-test-method test-addition ((test math-fixture)) +(def-test-method (test-addition test math-test-case :run nil) (let ((result (+ (numbera test) (numberb test)))) - (test-assert (= result 5)))) + (assert-true (= result 5)))) -(def-test-method test-subtraction ((test math-fixture)) +(def-test-method (test-subtraction test math-test-case :run nil) (let ((result (- (numberb test) (numbera test)))) (assert-equal result 1))) ;;; This method is meant to signal a failure -(def-test-method test-subtraction-2 ((test math-fixture)) +(def-test-method (test-subtraction-2 test math-test-case :run nil) (let ((result (- (numbera test) (numberb test)))) (assert-equal result 1))) ;;;; Finally we can run our test suite and see how it performs. -(textui-test-run (make-test-suite 'math-fixture)) +(textui-test-run (get-suite math-test-case))