RackUnit is a unit-testing framework for Racket.
Questions tagged [rackunit]
12 questions
7
votes
1 answer
RackUnit source location inside of macros
I am building a set of rackunit tests, where the actual test-case and check-equal? function is defined in a macro. The code looks something like this:
#lang racket
(require rackunit
rackunit/text-ui)
(define-syntax (my-test=? stx)
…

Leif Andersen
- 21,580
- 20
- 67
- 100
3
votes
1 answer
How to get rackunit to display stack trace?
I use rackunit like this in my code
(run-tests (test-suite "suite-name"
(test-case "case name"
...
))
I'm trying to practice TDD. When an assertion fails, I'm able to see which assertion failed. But in case of an error, unfortunately…

Peeyush Kushwaha
- 3,453
- 8
- 35
- 69
3
votes
1 answer
Monkey-patching with mock objects in Racket
Racket has some neat testing libraries, including Rackunit and Mock. I was wondering whether there's a standard way to monkey-patch internal calls in the function being tested (e.g. similar to python's mock.patch), either using these or other…

mindthief
- 12,755
- 14
- 57
- 61
3
votes
1 answer
Create a modified `equal?` function for use with RackUnit
I am writing a bunch of tests using check-equal? with objects that contain syntax objects that are not eq?. For the purposes of these tests, I am okay with saying that two syntax objects are equal if they're equal when given to syntax->datum. (Yes,…

Leif Andersen
- 21,580
- 20
- 67
- 100
2
votes
1 answer
Is it possible to use rackunit in DrRacket with language set to sicp, and if so, how?
I'm starting to work through SICP using DrRacket. I installed the sicp package, and declared #lang sicp at the top of the unit test file and then (require rackunit "xxx.scm"), but I get an unbound identifier error. Is there a mistake, or is it not…

RodPValley
- 29
- 1
- 5
2
votes
1 answer
Rackunit: in-depth check of exception type
In Rackunit, I know how to assert that an exception is thrown:
#lang racket
(module+ test
(require rackunit)
(check-exn exn:fail:contract? (lambda () (3 + 4))))
However, I cannot find a way to assert something more specific. Looking at the…

logc
- 3,813
- 1
- 18
- 29
1
vote
1 answer
Dynamically generating rackunit test-suite: tests pass and also raise exception
I am trying to dynamically generate a bunch of test cases.
Basically I want to run the same tests several times with different values. Maybe there's a better way to do that, if so let me know, I haven't found it yet.
I found make-test-suite which…

Anentropic
- 32,188
- 12
- 99
- 147
1
vote
1 answer
Logging Output from Racket Tests to File
I'm trying to set up a server to run extensive random tests against a Racket program, and want to have output from these tests sent to logs in files. How can I log output from tests to a file?
Tests from rackunit return #, not a string, so…

J Iguadeza
- 77
- 7
1
vote
1 answer
RackUnit check-eq? returns false for equal Strings
I am a little bit puzzled with RackUnit's check-eq? returning false for equal strings.
This is the code I am trying:
#lang racket
(require rackunit)
(define (get-output proc)
(let ([out (open-output-string)])
(parameterize…

Renato
- 12,940
- 3
- 54
- 85
1
vote
1 answer
Racket strange (require ...) semantics
I have a Racket code:
#lang racket
(provide (all-defined-out))
(struct weather (name perspective temperature humidity wind class)
#:transparent)
;;Exercise 8
;;Todo implement
#;(define (read-examples file-name)
(file->lines file-name))
;;todo…

UPvoter
- 45
- 7
0
votes
1 answer
Is there a way to limit or whitelist which files the command "raco test" should execute, based on file names or file extensions?
I'm writing unit tests using rackunit and running them using raco through the command raco test ., which recursively finds all racket files and executes them, including files that do not contain unit tests at all. It just runs everything.
According…

NPN328
- 1,863
- 3
- 27
- 47
0
votes
1 answer
How to use a unit-testing framework for a function that has a dynamic output in Racket?
I was doing exercise 3.5 on SICP book.
A Monte Carlo implementation in Racket generates the following code:
(define (monte-carlo trials experiment)
(define (iter trials-remaining trials-passed)
(cond ((= trials-remaining 0)
(/…
user4206400