This is the bytecurry.mocks Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 04:28:31 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
bytecurry.mocks
Tools to mock functions for unit tests
Thayne McCombs <astrothayne@gmail.com>
MIT
1.0.0
bytecurry.asdf-ext
(system).
package.lisp
(file).
mocks.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
bytecurry.mocks/bytecurry.mocks.asd
bytecurry.mocks
(system).
bytecurry.mocks/mocks.lisp
package.lisp
(file).
bytecurry.mocks
(system).
with-added-methods
(macro).
with-mocked-functions
(macro).
%get-binding-names
(function).
%let-expr
(function).
%setf-for-binding
(function).
%setf-for-original
(function).
Packages are listed by definition order.
bytecurry.mocks
Package to provide tools to mock functions
in common lisp unit tests.
Provides WITH-MOCKED-FUNCTIONS, which acts like FLET or LABELS, but shadows functions in the global scope, so that the function bindings are available outside of the lexical scope of the body. See docstring for more information.
mocks
common-lisp
.
with-added-methods
(macro).
with-mocked-functions
(macro).
%get-binding-names
(function).
%let-expr
(function).
%setf-for-binding
(function).
%setf-for-original
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Execute BODY with some extra methods.
This works similarly to WITH-MOCKED-FUNCTIONS. But defines methods instead of functions.
The bindings should look like DEFMETHOD definitions without the defmethod symbol.
One particularly useful scenario is to mock up an instance of a class by using eql specializers
for a local variable.
For now, it only supports adding new methods, not replacing existing methods, since it doesn’t restored the previous method. (mostly because I don’t know a good way to extract the specifiers from the definition form.)
Execute BODY with some functions mocked up.
BINDINGS is a list of function bindings, similar to those in FLET or LABELS.
Before executing BODY, the bindings are used to replace the definitions of functions,
and after BODY has finished, the original function definitions are restored.
You can use this macro to mock funtions for unit tests. For example, if function A calls
function B, you can replace the definition of B while testing A, to isolate the test on just
the behavior of A.
There are two things to note when using this macro:
1. You can’t mock functions in a locked package (such as CL)
2. The compiler may inline function calls, in which case changing the definition will have
no effect.
Get the let binding for a mock function binding
Store the mocked function.
Jump to: | %
F M W |
---|
Jump to: | %
F M W |
---|
Jump to: | B F M P S |
---|
Jump to: | B F M P S |
---|