3 unstable releases

0.2.0 Nov 12, 2024
0.1.1 Nov 12, 2024
0.1.0 Sep 11, 2024

#270 in Testing

Download history 147/week @ 2024-09-09 30/week @ 2024-09-16 9/week @ 2024-09-23 24/week @ 2024-09-30 5/week @ 2024-10-07 245/week @ 2024-11-11 19/week @ 2024-11-18 5/week @ 2024-11-25 19/week @ 2024-12-02

288 downloads per month
Used in patchify

MIT license

36KB
389 lines

Sham

Rust Crate version CI Docs License

/ʃam/
noun - a thing that is not what it is purported to be.
adjective - not genuine; fake or false.
verb - falsely present something as the truth.

Sham is a collection of useful mocks and fakes for testing Rust code. The primary purpose is to be able to swap out a genuine implementation and substitute it with a sham one, in order to achieve deterministic testing without side effects.

This is particularly useful for testing code that usually performs a particular operation that is either expensive, slow, or has side effects that are undesirable in a test environment, such as sending network requests. In these cases, a sham implementation can be used to simulate the real one, without actually performing the operation.

The modules provided are:

Note, each module is behind a feature flag, in order to keep the crate size down for those who don't need all the functionality.

reqwest

The reqwest module provides mocks for the Reqwest crate, which is a popular HTTP client for Rust.

std_process

The std_process module provides mocks for the Rust standard library's process module, mainly and most notably Command.

Dependencies

~0–11MB
~110K SLoC