1220a78ae2f4047c309a7d6be28dba89ec4791f2
[fiveam.git] / src / packages.lisp
1 ;; -*- lisp -*-
2
3 ;;;; * Introduction
4
5 ;;;; FiveAM is A simple Common Lisp unit testing library.
6
7 ;;;; FiveAM is a testing framework. It takes care of all the boring
8 ;;;; bookkeeping associated with managing a test framework allowing
9 ;;;; the developer to focus on writing tests and code.
10
11 ;;;; FiveAM was designed with the following premises:
12
13 ;;;; - Defining tests should be about writing tests, not
14 ;;;;   infrastructure. The developer should be able to focus on what
15 ;;;;   they're testing, not the testing framework.
16
17 ;;;; - Interactive testing is the norm. Common Lisp is an interactive
18 ;;;;  development environment, the testing environment should allow
19 ;;;;  the developer to quickly and easily redefine, change, remove
20 ;;;;  and run tests.
21
22 (defpackage :it.bese.FiveAM
23   (:use :common-lisp :it.bese.arnesi)
24   (:nicknames :5am)
25   (:export ;; creating tests and test-suites
26            #:make-suite
27            #:def-suite
28            #:in-suite
29            #:make-test
30            #:test
31            #:get-test
32            #:rem-test
33            ;; fixtures
34            #:make-fixture
35            #:def-fixture
36            #:with-fixture
37            #:get-fixture
38            #:rem-fixture
39            ;; running checks
40            #:is
41            #:is-true
42            #:is-false
43            #:signals
44            #:finishes
45            #:skip
46            #:pass
47            #:fail
48            #:*test-dribble*
49            ;; running tests
50            #:run
51            #:run-all-tests
52            #:explain
53            #:run!
54            #:!
55            #:!!
56            #:!!!
57            #:*debug-on-error*))
58
59 ;;;; You can use #+fiveam() to put your test-defining code
60 ;;;; inline with your other code - and not require people to
61 ;;;; have fiveam to run your package.
62 (pushnew :5am *features*)
63
64 ;;;;@include "check.lisp"
65
66 ;;;;@include "test.lisp"
67
68 ;;;;@include "fixture.lisp"
69
70 ;;;;@include "suite.lisp"
71
72 ;;;;@include "run.lisp"
73
74 ;;;;@include "explain.lisp"
75
76 ;;;; * Examples
77
78 #| (def-suite my-suite :description "My Example Suite")
79
80  (in-suite my-suite)
81
82  (test my-tests
83   "Example"
84   (is (= 4 (+ 2 2)) "2 plus 2 wasn't equal to 4 (using #'= to test equality)")
85   (is (= 0 (+ -1 1)))
86   (throws (error "Trying to add 4 to FOO didn't signal an error")
87      (+ 'foo 4))
88   (is (= 0 (+ 1 1)) "this should have failed"))
89
90  (run! 'my-suite)
91 ;; Running suite MY-SUITE
92 ..F.
93 Suite My Example Suite ran 4 tests (3/0/1) - 1 FAILED -
94 Failed Tests:
95 MY-TESTS FAILED: (+ 1 1) was not = to 0 (returned 2 instead)
96    Description: Example.
97    Message:     this should have failed
98 NIL |#
99
100 ;;;; * Colophon
101
102 ;;;; This documentaion was written by Edward Marco Baringer
103 ;;;; <mb@bese.it> and generated by qbook.
104
105 ;;;; ** COPYRIGHT
106
107 ;;;; Copyright (c) 2002-2003, Edward Marco Baringer
108 ;;;; All rights reserved. 
109  
110 ;;;; Redistribution and use in source and binary forms, with or without
111 ;;;; modification, are permitted provided that the following conditions are
112 ;;;; met:
113  
114 ;;;;  - Redistributions of source code must retain the above copyright
115 ;;;;    notice, this list of conditions and the following disclaimer.
116  
117 ;;;;  - Redistributions in binary form must reproduce the above copyright
118 ;;;;    notice, this list of conditions and the following disclaimer in the
119 ;;;;    documentation and/or other materials provided with the distribution.
120
121 ;;;;  - Neither the name of Edward Marco Baringer, nor BESE, nor the names
122 ;;;;    of its contributors may be used to endorse or promote products
123 ;;;;    derived from this software without specific prior written permission.
124  
125 ;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
126 ;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
127 ;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
128 ;;;; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
129 ;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
130 ;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
131 ;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
132 ;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
133 ;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
134 ;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
135 ;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE