Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jackfirth/racket-mock
Mocking library for Racket
https://github.com/jackfirth/racket-mock
mock racket testing
Last synced: 27 days ago
JSON representation
Mocking library for Racket
- Host: GitHub
- URL: https://github.com/jackfirth/racket-mock
- Owner: jackfirth
- License: other
- Created: 2015-08-19T23:44:44.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2020-10-23T07:08:22.000Z (about 4 years ago)
- Last Synced: 2024-08-03T22:06:19.221Z (3 months ago)
- Topics: mock, racket, testing
- Language: Racket
- Size: 172 KB
- Stars: 22
- Watchers: 4
- Forks: 7
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-racket-and-scheme - racket-mock
README
# racket-mock [![Build Status](https://travis-ci.org/jackfirth/racket-mock.svg?branch=master)](https://travis-ci.org/jackfirth/racket-mock) [![codecov](https://codecov.io/gh/jackfirth/racket-mock/branch/master/graph/badge.svg)](https://codecov.io/gh/jackfirth/racket-mock) [![Stories in Ready](https://badge.waffle.io/jackfirth/racket-mock.png?label=ready&title=Ready)](https://waffle.io/jackfirth/racket-mock)
Mocks for Racket testing.```bash
raco pkg install mock
raco pkg install mock-rackunit # RackUnit integration
```Documentation: [`mock`](http://docs.racket-lang.org/mock@mock/index.html), [`mock-rackunit`](http://docs.racket-lang.org/mock-rackunit@mock-rackunit/index.html)
This library defines *mocks*, which are "fake" implementations of functions that record calls made to them.
Two separate packages are provided, the main package `mock` and the RackUnit checks package `mock-rackunit`.
In standard uses, the `mock-rackunit` dependency is needed only for test code. For a thorough introduction, see [The Mock Guide](http://docs.racket-lang.org/mock@mock/mock-guide.html). For a full API reference, see [The Mock Reference](http://docs.racket-lang.org/mock@mock/mock-reference.html).Example:
```racket
(require mock mock/rackunit)(define/mock (foo)
; in test, don't call the real bar
#:mock bar #:as bar-mock #:with-behavior (const "wow!")
(bar))(define (bar) "bam!")
(foo) ; "bam!"
(with-mocks foo
(foo) ; "wow!"
(check-mock-num-calls 1 bar-mock))
```