Download testing.ss to your computer. Use DrScheme's "Language" / "Add Teachpack ..." menu option to add this teachpack. The testing teachpack provides the functions below, which help us make and use test cases.
This teachpack provides four constructs for testing programs:
The first three forms create tests:
You should place them below the relevant function definitions in the Definitions Window. Eventually you should place all tests, such as these, at the bottom of the window.
Finally, generate-report
is a function that displays
statistics of running tests:
Example: Place the following seven lines into the Definitions Window and click RUN:
(check-expect (+ 1 1) 2)
(check-expect (+ 1 1) 3)
(check-within (+ 1 1) 2.1 .001)
(check-within (+ 1 1) 2.1 .1)
(check-error (+ 1 1) "3")
(check-error (/ 1 0) "/: division by zero")
(generate-report)
Before you do so, try to figure out which of these tests succeed and which fail. After clicking run, you see a separate frame that records how many succeeded and failed and detail information about the failures, including links for highlighting the source.