3 (asdf:oos 'asdf:load-op :FiveAM)
5 (defpackage :it.bese.FiveAM.example
9 (in-package :it.bese.FiveAM.example)
11 ;;; First we need some functions to test.
19 ;;; Now we need to create a test which makes sure that add-2 and add-4
20 ;;; work as specified.
22 ;; we create a test named ADD-2 and supply a short description.
24 "Test the ADD-2 function" ;; a short description
27 (is (= 0 (add-2 -2))))
29 ;; we can already run add-2. This will return the list of test
30 ;; results, it should be a list of two test-passed objects.
34 ;; since we'd like to have some kind of readbale output we'll explain
39 ;; or we could do both at once:
43 ;;; So now we've defined and run a single test. Since we plan on
44 ;;; having more than one test and we'd like to run them together let's
45 ;;; create a simple test suite.
47 (def-suite example-suite :description "The example test suite.")
49 ;; we could explictly specify that every test we create is in the the
50 ;; example-suite suite, but it's easier to just change the default
53 (in-suite example-suite)
55 ;; now we'll create a new test for the add-4 function.
58 (is (= 0 (add-4 -4))))
60 ;; now let's run the test
64 ;; we can get the same effect by running the suite:
68 ;; since we'd like both add-2 and add-4 to be in the same suite, let's
69 ;; redefine add-2 to be in this suite:
71 (test add-2 "Test the ADD-2 function"
73 (is (= 0 (add-2 -2))))
75 ;; now we can run the suite and we'll see that both add-2 and add-4
76 ;; have been run (we know this since we no get 4 checks as opposed to
81 ;; Just for fun let's see what happens when a test fails. Again we'll
82 ;; redefine add-2, but add in a third, failing, check:
84 (test add-2 "Test the ADD-2 function"