Initial version of random testing
[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            #:for-all
50            #:gen-integer
51            #:gen-string
52            #:gen-character
53            ;; running tests
54            #:run
55            #:run-all-tests
56            #:explain
57            #:run!
58            #:!
59            #:!!
60            #:!!!
61            #:*debug-on-error*
62            #:*debug-on-failure*
63            #:*verbose-failures*))
64
65 ;;;; You can use #+5am to put your test-defining code inline with your
66 ;;;; other code - and not require people to have fiveam to run your
67 ;;;; package.
68
69 (pushnew :5am *features*)
70
71 ;;;;@include "check.lisp"
72
73 ;;;;@include "test.lisp"
74
75 ;;;;@include "fixture.lisp"
76
77 ;;;;@include "suite.lisp"
78
79 ;;;;@include "run.lisp"
80
81 ;;;;@include "explain.lisp"
82
83 ;;;; * Examples
84
85 #| (def-suite my-suite :description "My Example Suite")
86
87  (in-suite my-suite)
88
89  (test my-tests
90   "Example"
91   (is (= 4 (+ 2 2)) "2 plus 2 wasn't equal to 4 (using #'= to test equality)")
92   (is (= 0 (+ -1 1)))
93   (throws (error "Trying to add 4 to FOO didn't signal an error")
94      (+ 'foo 4))
95   (is (= 0 (+ 1 1)) "this should have failed"))
96
97  (run! 'my-suite)
98 ;; Running suite MY-SUITE
99 ..F.
100 Suite My Example Suite ran 4 tests (3/0/1) - 1 FAILED -
101 Failed Tests:
102 MY-TESTS FAILED: (+ 1 1) was not = to 0 (returned 2 instead)
103    Description: Example.
104    Message:     this should have failed
105 NIL |#
106
107 ;;;; * Colophon
108
109 ;;;; This documentaion was written by Edward Marco Baringer
110 ;;;; <mb@bese.it> and generated by qbook.
111
112 ;;;; ** COPYRIGHT
113
114 ;;;; Copyright (c) 2002-2003, Edward Marco Baringer
115 ;;;; All rights reserved. 
116  
117 ;;;; Redistribution and use in source and binary forms, with or without
118 ;;;; modification, are permitted provided that the following conditions are
119 ;;;; met:
120  
121 ;;;;  - Redistributions of source code must retain the above copyright
122 ;;;;    notice, this list of conditions and the following disclaimer.
123  
124 ;;;;  - Redistributions in binary form must reproduce the above copyright
125 ;;;;    notice, this list of conditions and the following disclaimer in the
126 ;;;;    documentation and/or other materials provided with the distribution.
127
128 ;;;;  - Neither the name of Edward Marco Baringer, nor BESE, nor the names
129 ;;;;    of its contributors may be used to endorse or promote products
130 ;;;;    derived from this software without specific prior written permission.
131  
132 ;;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
133 ;;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
134 ;;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
135 ;;;; A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT
136 ;;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
137 ;;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
138 ;;;; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
139 ;;;; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
140 ;;;; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
141 ;;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
142 ;;;; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE