Renaming rktunit to racunit
original commit: bc5cf30ebe1ba3743f7097d81ebf1297435e0201
This commit is contained in:
commit
7e3a6cd862
|
@ -6,7 +6,7 @@
|
|||
(define (test/gui . tests)
|
||||
(apply (make-gui-runner) tests))
|
||||
|
||||
(define test/c (or/c rktunit-test-case? rktunit-test-suite?))
|
||||
(define test/c (or/c racunit-test-case? racunit-test-suite?))
|
||||
|
||||
(provide/contract
|
||||
[test/gui
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
;; struct test :
|
||||
(define-struct test ())
|
||||
;; struct (rktunit-test-case test) : (U string #f) thunk
|
||||
(define-struct (rktunit-test-case test) (name action) #:transparent)
|
||||
;; struct (rktunit-test-suite test) : string (fdown fup fhere seed -> (listof test-result)) thunk thunk
|
||||
(define-struct (rktunit-test-suite test) (name tests before after) #:transparent)
|
||||
;; struct (racunit-test-case test) : (U string #f) thunk
|
||||
(define-struct (racunit-test-case test) (name action) #:transparent)
|
||||
;; struct (racunit-test-suite test) : string (fdown fup fhere seed -> (listof test-result)) thunk thunk
|
||||
(define-struct (racunit-test-suite test) (name tests before after) #:transparent)
|
||||
|
||||
;; struct exn:test exn : ()
|
||||
;;
|
||||
|
@ -33,10 +33,10 @@
|
|||
(define-struct (test-success test-result) (result))
|
||||
|
||||
(provide/contract
|
||||
(struct (rktunit-test-case test)
|
||||
(struct (racunit-test-case test)
|
||||
((name (or/c string? false/c))
|
||||
(action (-> any))))
|
||||
(struct (rktunit-test-suite test)
|
||||
(struct (racunit-test-suite test)
|
||||
((name string?)
|
||||
(tests procedure?)
|
||||
(before (-> any))
|
|
@ -11,7 +11,7 @@
|
|||
;; Infrastructure ----------------------------------------------
|
||||
|
||||
;; The continuation mark under which all check-info is keyed
|
||||
(define check-info-mark (gensym 'rktunit))
|
||||
(define check-info-mark (gensym 'racunit))
|
||||
|
||||
;; (continuation-mark-set -> (listof check-info))
|
||||
(define (check-info-stack marks)
|
|
@ -5,20 +5,20 @@
|
|||
|
||||
;; Frame size preferences
|
||||
|
||||
(preferences:set-default 'rktunit:frame:width 400 exact-positive-integer?)
|
||||
(preferences:set-default 'rktunit:frame:height 400 exact-positive-integer?)
|
||||
(define pref:width (pref:get/set 'rktunit:frame:width))
|
||||
(define pref:height (pref:get/set 'rktunit:frame:height))
|
||||
(preferences:set-default 'racunit:frame:width 400 exact-positive-integer?)
|
||||
(preferences:set-default 'racunit:frame:height 400 exact-positive-integer?)
|
||||
(define pref:width (pref:get/set 'racunit:frame:width))
|
||||
(define pref:height (pref:get/set 'racunit:frame:height))
|
||||
|
||||
;; CONSTANTS
|
||||
;; Some of these are obsolete, given the preferences above.
|
||||
|
||||
(define DETAILS-CANVAS-INIT-WIDTH 400)
|
||||
(define FRAME-LABEL "RktUnit")
|
||||
(define FRAME-LABEL "RacUnit")
|
||||
(define FRAME-INIT-HEIGHT 400)
|
||||
(define TREE-INIT-WIDTH 240)
|
||||
(define TREE-COLORIZE-CASES #t)
|
||||
(define DIALOG-ERROR-TITLE "RktUnit: Error")
|
||||
(define DIALOG-ERROR-TITLE "RacUnit: Error")
|
||||
(define STATUS-SUCCESS 'success)
|
||||
(define STATUS-FAILURE 'failure)
|
||||
(define STATUS-ERROR 'error)
|
|
@ -25,18 +25,18 @@
|
|||
;; create-model : test suite<%>/#f -> result<%>
|
||||
(define/public (create-model test parent)
|
||||
(define result
|
||||
(cond [(rktunit-test-case? test)
|
||||
(cond [(racunit-test-case? test)
|
||||
(new case-result%
|
||||
(controller this)
|
||||
(test test)
|
||||
(name (or (rktunit-test-case-name test)
|
||||
(name (or (racunit-test-case-name test)
|
||||
"<unnamed test-case>"))
|
||||
(parent parent))]
|
||||
[(rktunit-test-suite? test)
|
||||
[(racunit-test-suite? test)
|
||||
(new suite-result%
|
||||
(controller this)
|
||||
(test test)
|
||||
(name (or (rktunit-test-suite-name test)
|
||||
(name (or (racunit-test-suite-name test)
|
||||
"<unnamed test-suite>"))
|
||||
(parent parent))]))
|
||||
(send/i view view<%> create-view-link result parent)
|
|
@ -48,8 +48,8 @@
|
|||
#|
|
||||
(define/public (run)
|
||||
(let ([custodian (make-custodian)]
|
||||
[before (rktunit-test-suite-before test)]
|
||||
[after (rktunit-test-suite-after test)])
|
||||
[before (racunit-test-suite-before test)]
|
||||
[after (racunit-test-suite-after test)])
|
||||
(parameterize [(current-custodian custodian)]
|
||||
(dynamic-wind
|
||||
before
|
||||
|
@ -112,8 +112,8 @@
|
|||
(call-with-continuation-prompt
|
||||
(lambda ()
|
||||
(time-apply run-test-case
|
||||
(list (rktunit-test-case-name test)
|
||||
(rktunit-test-case-action test)))))])
|
||||
(list (racunit-test-case-name test)
|
||||
(racunit-test-case-action test)))))])
|
||||
(values (car results) (list cputime realtime gctime))))
|
||||
|
||||
(define (make-output-ports)
|
Before Width: | Height: | Size: 513 B After Width: | Height: | Size: 513 B |
|
@ -7,7 +7,7 @@
|
|||
|
||||
(provide insert-text
|
||||
ext:text%
|
||||
rktunit-style-map)
|
||||
racunit-style-map)
|
||||
|
||||
;; insert-text : text% string style-delta% -> void
|
||||
(define (insert-text e text style)
|
||||
|
@ -20,7 +20,7 @@
|
|||
|
||||
(define ext:text-mixin
|
||||
(mixin (text<%>) ()
|
||||
(init-field (style-map rktunit-style-map))
|
||||
(init-field (style-map racunit-style-map))
|
||||
(inherit last-position
|
||||
change-style
|
||||
set-clickback
|
||||
|
@ -139,7 +139,7 @@
|
|||
[error . ,style:red]
|
||||
[value . ,style:darkblue]))
|
||||
|
||||
(define rktunit-styles
|
||||
(define racunit-styles
|
||||
`([test-unexecuted . ,style:gray]
|
||||
[test-success . ,style:green]
|
||||
[test-failure . ,style:red]
|
||||
|
@ -181,7 +181,7 @@
|
|||
(extend-style-map empty-style-map
|
||||
basic-styles))
|
||||
|
||||
;; rktunit-style-map : style-map<%>
|
||||
(define rktunit-style-map
|
||||
;; racunit-style-map : style-map<%>
|
||||
(define racunit-style-map
|
||||
(extend-style-map basic-style-map
|
||||
rktunit-styles))
|
||||
racunit-styles))
|
|
@ -13,7 +13,7 @@
|
|||
(provide make-view-frame
|
||||
view%)
|
||||
|
||||
(define style-map rktunit-style-map)
|
||||
(define style-map racunit-style-map)
|
||||
|
||||
#|
|
||||
|
||||
|
@ -50,7 +50,7 @@ still be there, just not visible?
|
|||
controller)
|
||||
(super-new)
|
||||
|
||||
(define editor (new ext:text% (style-map rktunit-style-map)))
|
||||
(define editor (new ext:text% (style-map racunit-style-map)))
|
||||
(define renderer
|
||||
(new model-renderer%
|
||||
(controller controller)
|
||||
|
@ -146,7 +146,7 @@ still be there, just not visible?
|
|||
;; If the view-link has not been created,
|
||||
;; yield until it is.
|
||||
(unless (yield)
|
||||
(error 'rktunit-gui
|
||||
(error 'racunit-gui
|
||||
"internal error: no progress waiting for view-link"))
|
||||
(do-model-update model)])))
|
||||
|
|
@ -51,12 +51,12 @@
|
|||
;; data so FP is a bit ugly].
|
||||
(define (foldts fdown fup fhere seed test)
|
||||
(cond
|
||||
((rktunit-test-case? test)
|
||||
((racunit-test-case? test)
|
||||
(fhere test
|
||||
(rktunit-test-case-name test)
|
||||
(rktunit-test-case-action test)
|
||||
(racunit-test-case-name test)
|
||||
(racunit-test-case-action test)
|
||||
seed))
|
||||
((rktunit-test-suite? test)
|
||||
((racunit-test-suite? test)
|
||||
(apply-test-suite test fdown fup fhere seed))
|
||||
(else
|
||||
(raise
|
|
@ -27,14 +27,14 @@
|
|||
(define (test-suite-test-case-around fhere)
|
||||
(lambda (thunk)
|
||||
(let* ([name (current-test-name)]
|
||||
[test (make-rktunit-test-case name thunk)]
|
||||
[test (make-racunit-test-case name thunk)]
|
||||
[seed (current-seed)])
|
||||
(current-seed (fhere test name thunk seed)))))
|
||||
|
||||
(define (test-suite-check-around fhere)
|
||||
(lambda (thunk)
|
||||
(let* ([name #f]
|
||||
[test (make-rktunit-test-case name thunk)]
|
||||
[test (make-racunit-test-case name thunk)]
|
||||
[seed (current-seed)])
|
||||
(current-seed (fhere test name thunk seed)))))
|
||||
|
||||
|
@ -42,12 +42,12 @@
|
|||
(define delayed-test-case-around
|
||||
(lambda (thunk)
|
||||
(let ([name (current-test-name)])
|
||||
(make-rktunit-test-case name thunk))))
|
||||
(make-racunit-test-case name thunk))))
|
||||
|
||||
(define delayed-check-around
|
||||
(lambda (thunk)
|
||||
(let ([name #f])
|
||||
(make-rktunit-test-case name thunk))))
|
||||
(make-racunit-test-case name thunk))))
|
||||
|
||||
(define-syntax delay-test
|
||||
(syntax-rules ()
|
||||
|
@ -58,12 +58,12 @@
|
|||
test test1 ...)]))
|
||||
|
||||
(define (apply-test-suite suite fdown fup fhere seed)
|
||||
(let* ([name (rktunit-test-suite-name suite)]
|
||||
[tests (rktunit-test-suite-tests suite)]
|
||||
[before (rktunit-test-suite-before suite)]
|
||||
[after (rktunit-test-suite-after suite)]
|
||||
(let* ([name (racunit-test-suite-name suite)]
|
||||
[tests (racunit-test-suite-tests suite)]
|
||||
[before (racunit-test-suite-before suite)]
|
||||
[after (racunit-test-suite-after suite)]
|
||||
[kid-seed (fdown suite name before after seed)]
|
||||
[kid-seed ((rktunit-test-suite-tests suite) fdown fup fhere kid-seed)])
|
||||
[kid-seed ((racunit-test-suite-tests suite) fdown fup fhere kid-seed)])
|
||||
(fup suite name before after seed kid-seed)))
|
||||
|
||||
;; test-suite : name [#:before thunk] [#:after thunk] test ...
|
||||
|
@ -84,7 +84,7 @@
|
|||
[the-tests
|
||||
(lambda (fdown fup fhere seed)
|
||||
(define (run/inner x)
|
||||
(cond [(rktunit-test-suite? x)
|
||||
(cond [(racunit-test-suite? x)
|
||||
(current-seed
|
||||
(apply-test-suite x fdown fup fhere (current-seed)))]
|
||||
[(list? x)
|
||||
|
@ -103,7 +103,7 @@
|
|||
[(not (string? the-name))
|
||||
(raise-type-error 'test-suite "test-suite name as string" the-name)]
|
||||
[else
|
||||
(make-rktunit-test-suite
|
||||
(make-racunit-test-suite
|
||||
the-name
|
||||
the-tests
|
||||
before-thunk
|
||||
|
@ -138,13 +138,13 @@
|
|||
(for-each
|
||||
(lambda (t)
|
||||
(cond
|
||||
[(rktunit-test-suite? t)
|
||||
[(racunit-test-suite? t)
|
||||
(current-seed (apply-test-suite t fdown fup fhere (current-seed)))]
|
||||
[(rktunit-test-case? t)
|
||||
[(racunit-test-case? t)
|
||||
(current-seed
|
||||
(fhere t
|
||||
(rktunit-test-case-name t)
|
||||
(rktunit-test-case-action t)
|
||||
(racunit-test-case-name t)
|
||||
(racunit-test-case-action t)
|
||||
(current-seed)))]
|
||||
[else
|
||||
(raise
|
||||
|
@ -158,7 +158,7 @@
|
|||
;;
|
||||
;; Construct a test suite from a list of tests
|
||||
(define (make-test-suite name #:before [before void-thunk] #:after [after void-thunk] tests)
|
||||
(make-rktunit-test-suite name
|
||||
(make-racunit-test-suite name
|
||||
(tests->test-suite-action tests)
|
||||
before
|
||||
after))
|
|
@ -15,8 +15,8 @@
|
|||
(struct-out test-failure)
|
||||
(struct-out test-error)
|
||||
(struct-out test-success)
|
||||
(struct-out rktunit-test-case)
|
||||
(struct-out rktunit-test-suite)
|
||||
(struct-out racunit-test-case)
|
||||
(struct-out racunit-test-suite)
|
||||
|
||||
with-check-info
|
||||
with-check-info*
|
||||
|
@ -42,9 +42,9 @@
|
|||
test-suite
|
||||
make-test-suite
|
||||
delay-test
|
||||
(rename-out [make-rktunit-test-case make-test-case]
|
||||
[rktunit-test-case? test-case?]
|
||||
[rktunit-test-suite? test-suite?])
|
||||
(rename-out [make-racunit-test-case make-test-case]
|
||||
[racunit-test-case? test-case?]
|
||||
[racunit-test-suite? test-suite?])
|
||||
|
||||
define-test-suite
|
||||
define/provide-test-suite
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@title{Acknowlegements}
|
||||
|
||||
The following people have contributed to RktUnit:
|
||||
The following people have contributed to RacUnit:
|
||||
|
||||
@itemize[
|
||||
@item{Robby Findler pushed me to release version 3}
|
||||
|
@ -12,7 +12,7 @@ The following people have contributed to RktUnit:
|
|||
suggested renaming @racket[test/text-ui]}
|
||||
|
||||
@item{Dave Gurnell reported a bug in check-not-exn and
|
||||
suggested improvements to RktUnit}
|
||||
suggested improvements to RacUnit}
|
||||
|
||||
@item{Danny Yoo reported a bug in and provided a fix for
|
||||
trim-current-directory}
|
||||
|
@ -30,7 +30,7 @@ The following people have contributed to RktUnit:
|
|||
@item{Jose A. Ortega Ruiz alerted me a problem in the
|
||||
packaging system and helped fix it.}
|
||||
|
||||
@item{Sebastian H. Seidel provided help packaging RktUnit
|
||||
@item{Sebastian H. Seidel provided help packaging RacUnit
|
||||
into a .plt}
|
||||
|
||||
@item{Don Blaheta provided the method for grabbing line number
|
|
@ -1,10 +1,10 @@
|
|||
#lang scribble/doc
|
||||
@(require "base.rkt")
|
||||
|
||||
@title[#:tag "api"]{RktUnit API}
|
||||
@title[#:tag "api"]{RacUnit API}
|
||||
|
||||
@defmodule[rktunit
|
||||
#:use-sources (rktunit)]
|
||||
@defmodule[racunit
|
||||
#:use-sources (racunit)]
|
||||
|
||||
@include-section["overview.scrbl"]
|
||||
@include-section["check.scrbl"]
|
|
@ -6,15 +6,15 @@
|
|||
|
||||
(for-label scheme/base
|
||||
scheme/contract
|
||||
rktunit
|
||||
rktunit/text-ui
|
||||
rktunit/gui))
|
||||
racunit
|
||||
racunit/text-ui
|
||||
racunit/gui))
|
||||
|
||||
(provide
|
||||
(all-from-out scribble/eval
|
||||
scribble/manual)
|
||||
(for-label (all-from-out scheme/base
|
||||
scheme/contract
|
||||
rktunit
|
||||
rktunit/text-ui
|
||||
rktunit/gui)))
|
||||
racunit
|
||||
racunit/text-ui
|
||||
racunit/gui)))
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
@title{Checks}
|
||||
|
||||
Checks are the basic building block of RktUnit. A check
|
||||
Checks are the basic building block of RacUnit. A check
|
||||
checks some condition. If the condition holds the check
|
||||
evaluates to @racket[#t]. If the condition doesn't hold the
|
||||
check raises an instance of @racket[exn:test:check] with
|
||||
|
@ -16,7 +16,7 @@ their arguments. You can use check as first class
|
|||
functions, though you will lose precision in the reported
|
||||
source locations if you do so.
|
||||
|
||||
The following are the basic checks RktUnit provides. You
|
||||
The following are the basic checks RacUnit provides. You
|
||||
can create your own checks using @racket[define-check].
|
||||
|
||||
@defproc[(check (op (-> any any any))
|
|
@ -147,7 +147,7 @@ creates test cases within the suite, with the given names and
|
|||
body expressions.
|
||||
|
||||
As far I know no-one uses this macro, so it might disappear
|
||||
in future versions of RktUnit.}
|
||||
in future versions of RacUnit.}
|
||||
}
|
||||
|
||||
|
|
@ -48,5 +48,5 @@ file. The after action deletes it.
|
|||
This somewhat curious macro evaluates the given tests in a
|
||||
context where @racket[current-test-case-around] is
|
||||
parameterized to @racket[test-suite-test-case-around]. This
|
||||
has been useful in testing RktUnit. It might be useful
|
||||
has been useful in testing RacUnit. It might be useful
|
||||
for you if you create test cases that create test cases.}
|
|
@ -1,6 +1,6 @@
|
|||
#lang scheme/base
|
||||
|
||||
(require rktunit
|
||||
(require racunit
|
||||
"file.rkt")
|
||||
|
||||
(check-equal? (my-+ 1 1) 2)
|
|
@ -14,8 +14,8 @@ Note that @racket[require/expose] can be a bit fragile,
|
|||
especially when mixed with compiled code. Use at your own risk!
|
||||
}
|
||||
|
||||
This example gets @racket[make-failure-test], which is defined in a RktUnit test:
|
||||
This example gets @racket[make-failure-test], which is defined in a RacUnit test:
|
||||
|
||||
@racketblock[
|
||||
(require/expose rktunit/private/check-test (make-failure-test))
|
||||
(require/expose racunit/private/check-test (make-failure-test))
|
||||
]
|
|
@ -1,9 +1,9 @@
|
|||
#lang scribble/doc
|
||||
@(require "base.rkt")
|
||||
|
||||
@title{Overview of RktUnit}
|
||||
@title{Overview of RacUnit}
|
||||
|
||||
There are three basic data types in RktUnit:
|
||||
There are three basic data types in RacUnit:
|
||||
|
||||
@itemize[
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
#lang scribble/doc
|
||||
@(require "base.rkt")
|
||||
|
||||
@title[#:tag "philosophy"]{The Philosophy of RktUnit}
|
||||
@title[#:tag "philosophy"]{The Philosophy of RacUnit}
|
||||
|
||||
RktUnit is designed to allow tests to evolve in step with
|
||||
the evolution of the program under testing. RktUnit
|
||||
RacUnit is designed to allow tests to evolve in step with
|
||||
the evolution of the program under testing. RacUnit
|
||||
scales from the unstructed checks suitable for simple
|
||||
programs to the complex structure necessary for large
|
||||
projects.
|
||||
|
@ -25,9 +25,9 @@ checking are of the form:
|
|||
(equal? (length '(a b)) 2)
|
||||
]
|
||||
|
||||
RktUnit directly supports this style of testing. A check
|
||||
RacUnit directly supports this style of testing. A check
|
||||
on its own is a valid test. So the above examples may be
|
||||
written in RktUnit as:
|
||||
written in RacUnit as:
|
||||
|
||||
@racketblock[
|
||||
(check-equal? (length null) 0)
|
||||
|
@ -35,7 +35,7 @@ written in RktUnit as:
|
|||
(check-equal? (length '(a b)) 2)
|
||||
]
|
||||
|
||||
Simple programs now get all the benefits of RktUnit with
|
||||
Simple programs now get all the benefits of RacUnit with
|
||||
very little overhead.
|
||||
|
||||
There are limitations to this style of testing that more
|
||||
|
@ -45,7 +45,7 @@ it does not make sense to evaluate some expressions if
|
|||
earlier ones have failed. This type of program needs a way
|
||||
to group expressions so that a failure in one group causes
|
||||
evaluation of that group to stop and immediately proceed to
|
||||
the next group. In RktUnit all that is required is to
|
||||
the next group. In RacUnit all that is required is to
|
||||
wrap a @racket[test-begin] expression around a group of
|
||||
expressions:
|
||||
|
||||
|
@ -62,7 +62,7 @@ be evaluated.
|
|||
|
||||
Notice that all the previous tests written in the simple
|
||||
style are still valid. Introducing grouping is a local
|
||||
change only. This is a key feature of RktUnit's support
|
||||
change only. This is a key feature of RacUnit's support
|
||||
for the evolution of the program.
|
||||
|
||||
The programmer may wish to name a group of tests. This is
|
||||
|
@ -79,7 +79,7 @@ Most programs will stick with this style. However,
|
|||
programmers writing very complex programs may wish to
|
||||
maintain separate groups of tests for different parts of the
|
||||
program, or run their tests in different ways to the normal
|
||||
RktUnit manner (for example, test results may be logged
|
||||
RacUnit manner (for example, test results may be logged
|
||||
for the purpose of improving software quality, or they may
|
||||
be displayed on a website to indicate service quality). For
|
||||
these programmers it is necessary to delay the execution of
|
||||
|
@ -104,15 +104,15 @@ outside the suite continue to evaluate as before.
|
|||
@section{Historical Context}
|
||||
|
||||
Most testing frameworks, including earlier versions of
|
||||
RktUnit, support only the final form of testing. This is
|
||||
RacUnit, support only the final form of testing. This is
|
||||
likely due to the influence of the SUnit testing framework,
|
||||
which is the ancestor of RktUnit and the most widely used
|
||||
which is the ancestor of RacUnit and the most widely used
|
||||
frameworks in Java, .Net, Python, and Ruby, and many other
|
||||
languages. That this is insufficient for all users is
|
||||
apparent if one considers the proliferation of ``simpler''
|
||||
testing frameworks in Racket such as SRFI-78, or the
|
||||
practice of beginner programmers. Unfortunately these
|
||||
simpler methods are inadequate for testing larger
|
||||
systems. To the best of my knowledge RktUnit is the only
|
||||
systems. To the best of my knowledge RacUnit is the only
|
||||
testing framework that makes a conscious effort to support
|
||||
the testing style of all levels of programmer.
|
|
@ -1,7 +1,7 @@
|
|||
#lang scribble/doc
|
||||
@(require "base.rkt")
|
||||
|
||||
@title[#:tag "quick-start"]{Quick Start Guide for RktUnit}
|
||||
@title[#:tag "quick-start"]{Quick Start Guide for RacUnit}
|
||||
|
||||
Suppose we have code contained in @tt{file.rkt}, which
|
||||
implements buggy versions of @racket[+] and @racket[-]
|
||||
|
@ -24,15 +24,15 @@ racket/base
|
|||
my-*)
|
||||
]
|
||||
|
||||
We want to test this code with RktUnit. We start by
|
||||
We want to test this code with RacUnit. We start by
|
||||
creating a file called @tt{file-test.rkt} to contain our
|
||||
tests. At the top of @tt{file-test.rkt} we import
|
||||
RktUnit and @tt{file.rkt}:
|
||||
RacUnit and @tt{file.rkt}:
|
||||
|
||||
@racketmod[
|
||||
racket/base
|
||||
|
||||
(require rktunit
|
||||
(require racunit
|
||||
"file.rkt")
|
||||
]
|
||||
|
||||
|
@ -43,7 +43,7 @@ Now we add some tests to check our library:
|
|||
(check-equal? (my-* 1 2) 2 "Simple multiplication")
|
||||
]
|
||||
|
||||
This is all it takes to define tests in RktUnit. Now
|
||||
This is all it takes to define tests in RacUnit. Now
|
||||
evaluate this file and see if the library is correct.
|
||||
Here's the result I get:
|
||||
|
||||
|
@ -63,13 +63,13 @@ expected: 2
|
|||
The first @racket[#t] indicates the first test passed. The
|
||||
second test failed, as shown by the message.
|
||||
|
||||
Requiring RktUnit and writing checks is all you need to
|
||||
Requiring RacUnit and writing checks is all you need to
|
||||
get started testing, but let's take a little bit more time
|
||||
to look at some features beyond the essentials.
|
||||
|
||||
Let's say we want to check that a number of properties hold.
|
||||
How do we do this? So far we've only seen checks of a
|
||||
single expression. In RktUnit a check is always a single
|
||||
single expression. In RacUnit a check is always a single
|
||||
expression, but we can group checks into units called test
|
||||
cases. Here's a simple test case written using the
|
||||
@racket[test-begin] form:
|
||||
|
@ -91,7 +91,7 @@ Evalute this and you should see an error message like:
|
|||
A test
|
||||
... has a FAILURE
|
||||
name: check-pred
|
||||
location: (#<path:/Users/noel/programming/schematics/rktunit/branches/v3/doc/file-test.rkt> 14 6 252 22)
|
||||
location: (#<path:/Users/noel/programming/schematics/racunit/branches/v3/doc/file-test.rkt> 14 6 252 22)
|
||||
expression: (check-pred even? elt)
|
||||
params: (#<procedure:even?> 9)
|
||||
--------------------
|
||||
|
@ -147,13 +147,13 @@ tests, allowing you to choose how you run your tests. You
|
|||
might, for example, print the results to the screen or log
|
||||
them to a file.
|
||||
|
||||
Let's run our tests, using RktUnit's simple textual user
|
||||
Let's run our tests, using RacUnit's simple textual user
|
||||
interface (there are fancier interfaces available but this
|
||||
will do for our example). In @tt{file-test.rkt} add the
|
||||
following lines:
|
||||
|
||||
@racketblock[
|
||||
(require rktunit/text-ui)
|
||||
(require racunit/text-ui)
|
||||
|
||||
(run-tests file-tests)
|
||||
]
|
||||
|
@ -161,6 +161,6 @@ following lines:
|
|||
Now evaluate the file and you should see similar output
|
||||
again.
|
||||
|
||||
These are the basics of RktUnit. Refer to the
|
||||
These are the basics of RacUnit. Refer to the
|
||||
documentation below for more advanced topics, such as
|
||||
defining your own checks. Have fun!
|
|
@ -1,12 +1,12 @@
|
|||
#lang scribble/doc
|
||||
@(require "base.rkt")
|
||||
|
||||
@title{@bold{RktUnit}: Unit Testing for Racket}
|
||||
@title{@bold{RacUnit}: Unit Testing for Racket}
|
||||
|
||||
@author[(author+email "Noel Welsh" "noelwelsh@gmail.com")
|
||||
(author+email "Ryan Culpepper" "ryan_sml@yahoo.com")]
|
||||
|
||||
RktUnit is a unit-testing framework for Racket. It
|
||||
RacUnit is a unit-testing framework for Racket. It
|
||||
is designed to handle the needs of all Racket programmers,
|
||||
from novices to experts.
|
||||
|
|
@ -12,7 +12,7 @@ There are also miscellaneous Scribble fixes.
|
|||
|
||||
@section{Version 3}
|
||||
|
||||
This version of RktUnit is largely backwards compatible
|
||||
This version of RacUnit is largely backwards compatible
|
||||
with version 2 but there are significant changes to the
|
||||
underlying model, justifying incrementing the major version
|
||||
number. These changes are best explained in
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
@title[#:tag "ui"]{User Interfaces}
|
||||
|
||||
RktUnit provides a textual and a graphical user interface
|
||||
RacUnit provides a textual and a graphical user interface
|
||||
|
||||
@section{Textual User Interface}
|
||||
|
||||
@defmodule[rktunit/text-ui]
|
||||
@defmodule[racunit/text-ui]
|
||||
|
||||
The textual UI is in the @racketmodname[rktunit/text-ui] module.
|
||||
The textual UI is in the @racketmodname[racunit/text-ui] module.
|
||||
It is run via the @racket[run-tests] function.
|
||||
|
||||
@defproc[(run-tests (test (or/c test-case? test-suite?))
|
||||
|
@ -33,15 +33,15 @@ information.
|
|||
|
||||
@section{Graphical User Interface}
|
||||
|
||||
@defmodule[rktunit/gui]
|
||||
@defmodule[racunit/gui]
|
||||
|
||||
RktUnit also provides a GUI test runner, available from the
|
||||
@racketmodname[rktunit/gui] module.
|
||||
RacUnit also provides a GUI test runner, available from the
|
||||
@racketmodname[racunit/gui] module.
|
||||
|
||||
@defproc[(test/gui [test (or/c test-case? test-suite?)] ...)
|
||||
any]{
|
||||
|
||||
Creates a new RktUnit GUI window and runs each @racket[test]. The
|
||||
Creates a new RacUnit GUI window and runs each @racket[test]. The
|
||||
GUI is updated as tests complete.
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ GUI is updated as tests complete.
|
|||
@defproc[(make-gui-runner)
|
||||
(-> (or/c test-case? test-suite?) ... any)]{
|
||||
|
||||
Creates a new RktUnit GUI window and returns a procedure that, when
|
||||
Creates a new RacUnit GUI window and returns a procedure that, when
|
||||
applied, runs the given tests and displays the results in the GUI.
|
||||
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
;; CONSTANTS
|
||||
|
||||
(define BACKTRACE-NO-MESSAGE "No message.")
|
||||
(define LINK-MODULE-SPEC 'rktunit/private/gui/drracket-link)
|
||||
(define LINK-MODULE-SPEC 'racunit/private/gui/drracket-link)
|
||||
|
||||
(define-namespace-anchor drracket-ns-anchor)
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
#lang racket
|
||||
(require rktunit/gui)
|
||||
(provide (all-from-out rktunit/gui))
|
||||
(require racunit/gui)
|
||||
(provide (all-from-out racunit/gui))
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#lang racket
|
||||
(require rktunit/text-ui)
|
||||
(provide (all-from-out rktunit/text-ui))
|
||||
(require racunit/text-ui)
|
||||
(provide (all-from-out racunit/text-ui))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
(require racunit
|
||||
"check-test.rkt"
|
||||
"check-info-test.rkt"
|
||||
"format-test.rkt"
|
||||
|
@ -17,12 +17,12 @@
|
|||
"counter-test.rkt"
|
||||
"text-ui-util-test.rkt")
|
||||
|
||||
(provide all-rktunit-tests
|
||||
(provide all-racunit-tests
|
||||
failure-tests)
|
||||
|
||||
(define all-rktunit-tests
|
||||
(define all-racunit-tests
|
||||
(test-suite
|
||||
"All RktUnit Tests"
|
||||
"All RacUnit Tests"
|
||||
check-tests
|
||||
base-tests
|
||||
check-info-tests
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/base)
|
||||
(require racunit
|
||||
racunit/private/base)
|
||||
|
||||
(provide base-tests)
|
||||
|
||||
|
@ -37,45 +37,45 @@
|
|||
(test-suite
|
||||
"All tests for base"
|
||||
(test-case
|
||||
"rktunit-test-case structure has a contract on name"
|
||||
"racunit-test-case structure has a contract on name"
|
||||
(check-exn exn:fail?
|
||||
(lambda ()
|
||||
(make-rktunit-test-case
|
||||
(make-racunit-test-case
|
||||
'foo
|
||||
(lambda () #t)))))
|
||||
(test-case
|
||||
"rktunit-test-case structure has a contract on action"
|
||||
"racunit-test-case structure has a contract on action"
|
||||
(check-exn exn:fail?
|
||||
(lambda ()
|
||||
(make-rktunit-test-case
|
||||
(make-racunit-test-case
|
||||
"Name"
|
||||
#f))))
|
||||
(test-case
|
||||
"rktunit-test-suite has a contract on its fields"
|
||||
"racunit-test-suite has a contract on its fields"
|
||||
(check-exn exn:fail?
|
||||
(lambda ()
|
||||
(make-rktunit-test-suite
|
||||
(make-racunit-test-suite
|
||||
#f
|
||||
(list)
|
||||
(lambda () 3)
|
||||
(lambda () 2))))
|
||||
(check-exn exn:fail?
|
||||
(lambda ()
|
||||
(make-rktunit-test-suite
|
||||
(make-racunit-test-suite
|
||||
"Name"
|
||||
#f
|
||||
(lambda () 3)
|
||||
(lambda () 2))))
|
||||
(check-exn exn:fail?
|
||||
(lambda ()
|
||||
(make-rktunit-test-suite
|
||||
(make-racunit-test-suite
|
||||
"Name"
|
||||
(list)
|
||||
#f
|
||||
(lambda () 2))))
|
||||
(check-exn exn:fail?
|
||||
(lambda ()
|
||||
(make-rktunit-test-suite
|
||||
(make-racunit-test-suite
|
||||
"Name"
|
||||
(list)
|
||||
(lambda () 3)
|
|
@ -4,20 +4,20 @@
|
|||
;;;
|
||||
;;; Copyright (C) 2003 by Noel Welsh.
|
||||
;;;
|
||||
;;; This file is part of RktUnit.
|
||||
;;; This file is part of RacUnit.
|
||||
|
||||
;;; RktUnit is free software; you can redistribute it and/or
|
||||
;;; RacUnit is free software; you can redistribute it and/or
|
||||
;;; modify it under the terms of the GNU Lesser General Public
|
||||
;;; License as published by the Free Software Foundation; either
|
||||
;;; version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
;;; RktUnitis distributed in the hope that it will be useful,
|
||||
;;; RacUnitis distributed in the hope that it will be useful,
|
||||
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;;; Lesser General Public License for more details.
|
||||
|
||||
;;; You should have received a copy of the GNU Lesser General Public
|
||||
;;; License along with RktUnit; if not, write to the Free Software
|
||||
;;; License along with RacUnit; if not, write to the Free Software
|
||||
;;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
;;; Author: Noel Welsh <noelwelsh@yahoo.com>
|
||||
|
@ -27,8 +27,8 @@
|
|||
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/check-info)
|
||||
(require racunit
|
||||
racunit/private/check-info)
|
||||
|
||||
(provide check-info-tests)
|
||||
|
|
@ -30,10 +30,10 @@
|
|||
|
||||
(require racket/runtime-path
|
||||
srfi/1
|
||||
rktunit
|
||||
rktunit/private/check
|
||||
rktunit/private/result
|
||||
rktunit/private/test-suite)
|
||||
racunit
|
||||
racunit/private/check
|
||||
racunit/private/result
|
||||
racunit/private/test-suite)
|
||||
|
||||
(provide check-tests)
|
||||
|
||||
|
@ -288,7 +288,7 @@
|
|||
(cns (current-namespace)))
|
||||
(parameterize ((current-namespace destns))
|
||||
(namespace-require '(for-syntax racket/base))
|
||||
(namespace-require 'rktunit/private/check)
|
||||
(namespace-require 'racunit/private/check)
|
||||
;; First check that the right check macro got
|
||||
;; used: ie that it didn't just compile the thing
|
||||
;; as an application.
|
|
@ -28,10 +28,10 @@
|
|||
#lang racket/base
|
||||
|
||||
(require racket/match
|
||||
rktunit
|
||||
rktunit/private/counter
|
||||
rktunit/private/monad
|
||||
rktunit/private/hash-monad)
|
||||
racunit
|
||||
racunit/private/counter
|
||||
racunit/private/monad
|
||||
racunit/private/hash-monad)
|
||||
|
||||
(provide counter-tests)
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/check-info
|
||||
rktunit/private/format)
|
||||
(require racunit
|
||||
racunit/private/check-info
|
||||
racunit/private/format)
|
||||
|
||||
(provide format-tests)
|
||||
|
|
@ -28,9 +28,9 @@
|
|||
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/monad
|
||||
rktunit/private/hash-monad)
|
||||
(require racunit
|
||||
racunit/private/monad
|
||||
racunit/private/hash-monad)
|
||||
|
||||
(provide hash-monad-tests)
|
||||
|
|
@ -27,8 +27,8 @@
|
|||
;; Commentary:
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/location)
|
||||
(require racunit
|
||||
racunit/private/location)
|
||||
|
||||
(provide location-tests)
|
||||
|
|
@ -29,8 +29,8 @@
|
|||
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/monad)
|
||||
(require racunit
|
||||
racunit/private/monad)
|
||||
|
||||
(provide monad-tests)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/result)
|
||||
(require racunit
|
||||
racunit/private/result)
|
||||
|
||||
(provide result-tests)
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/text-ui
|
||||
"all-rktunit-tests.rkt")
|
||||
(require racunit
|
||||
racunit/text-ui
|
||||
"all-racunit-tests.rkt")
|
||||
|
||||
(run-tests all-rktunit-tests)
|
||||
(run-tests all-racunit-tests)
|
||||
|
||||
;; These tests should all error, so we switch the meaning of correct and incorrect. If the error display changes significantly, DrDr will catch it
|
||||
(parameterize ([current-error-port (current-output-port)]
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit/private/check)
|
||||
(require racunit/private/check)
|
||||
|
||||
;; This check should succeed
|
||||
(check = 1 1 0.0)
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit/private/check
|
||||
rktunit/private/test-case)
|
||||
(require racunit/private/check
|
||||
racunit/private/test-case)
|
||||
|
||||
;; These tests should succeeds
|
||||
(test-begin (check-eq? 1 1))
|
|
@ -1,10 +1,10 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit/private/base
|
||||
rktunit/private/check
|
||||
rktunit/private/test-case
|
||||
rktunit/private/test-suite
|
||||
rktunit/private/result)
|
||||
(require racunit/private/base
|
||||
racunit/private/check
|
||||
racunit/private/test-case
|
||||
racunit/private/test-suite
|
||||
racunit/private/result)
|
||||
|
||||
(provide test-case-tests)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/check)
|
||||
(require racunit
|
||||
racunit/private/check)
|
||||
|
||||
(define run? #f)
|
||||
|
|
@ -4,9 +4,9 @@
|
|||
racket/runtime-path
|
||||
srfi/1
|
||||
srfi/13
|
||||
rktunit
|
||||
rktunit/private/util
|
||||
rktunit/private/location)
|
||||
racunit
|
||||
racunit/private/util
|
||||
racunit/private/location)
|
||||
|
||||
(provide test-tests)
|
||||
|
||||
|
@ -43,7 +43,7 @@
|
|||
(let ((destns (make-base-namespace))
|
||||
(cns (current-namespace)))
|
||||
(parameterize ((current-namespace destns))
|
||||
(namespace-require 'rktunit)
|
||||
(namespace-require 'racunit)
|
||||
(check-exn (lambda (e)
|
||||
(check-pred exn:fail:syntax? e)
|
||||
(check string-contains (exn-message e) msg))
|
|
@ -33,8 +33,8 @@
|
|||
racket/port
|
||||
srfi/1
|
||||
srfi/13
|
||||
rktunit
|
||||
rktunit/text-ui)
|
||||
racunit
|
||||
racunit/text-ui)
|
||||
|
||||
(provide text-ui-tests)
|
||||
|
||||
|
@ -119,9 +119,9 @@
|
|||
(with-all-output-to-string (failing-binary-test/complex-params)))])
|
||||
(check string-contains
|
||||
op
|
||||
"(`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))")))
|
||||
"`((0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))")))
|
||||
|
||||
(test-case
|
||||
"Non-binary check output is pretty printed"
|
||||
|
@ -129,9 +129,9 @@
|
|||
(with-all-output-to-string (failing-test/complex-params)))])
|
||||
(check string-contains
|
||||
op
|
||||
"(`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
`(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))")))
|
||||
"`((0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14)
|
||||
(0 1 2 3 4 5 6 7 8 9 10 11 12 13 14))")))
|
||||
|
||||
(test-case
|
||||
"Location trimmed when file is under current directory"
|
|
@ -27,8 +27,8 @@
|
|||
;; Commentary:
|
||||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/text-ui-util)
|
||||
(require racunit
|
||||
racunit/private/text-ui-util)
|
||||
|
||||
(provide text-ui-util-tests)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#lang racket/base
|
||||
|
||||
(require rktunit
|
||||
rktunit/private/util)
|
||||
(require racunit
|
||||
racunit/private/util)
|
||||
|
||||
(provide util-tests)
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
|||
(check-true (procedure? make-failure-test))
|
||||
(check-equal? (make-arity-at-least 2)
|
||||
(procedure-arity make-failure-test))
|
||||
(check-pred rktunit-test-case?
|
||||
(check-pred racunit-test-case?
|
||||
(delay-test (make-failure-test "foo" string?)))))
|
||||
|
||||
(test-case
|
Loading…
Reference in New Issue
Block a user