jtd-fuzz
jtd-fuzz
generates example data (aka "fuzz tests") from a JSON Typedef
schema.
|
A note on security: jtd-fuzz
does not use a cryptographically-secure
random-number generator. Do not use jtd-fuzz
to generate randomness, if that
randomness needs to be cryptographically secure.
Installation
To install jtd-fuzz
, you have a few options:
Install on macOS
You can install jtd-fuzz
via Homebrew:
Alternatively, you can download and extract the binary yourself from
x86_64-apple-darwin.zip
in the latest release. Because of Apple's
quarantine system, you will either need to run:
In order to be able to run the executable.
Install on Linux
Download and extract the binary from x86_64-unknown-linux-gnu.zip
in the
latest release.
Install on Windows
Download and extract the binary from x86_64-pc-windows-gnu.zip
in the latest
release. Runs on 64-bit MinGW for Windows 7+.
Install with Docker
This option is recommended if you're running jtd-fuzz
in some sort of script
and you want to make sure that everyone running the script uses the same version
of jtd-fuzz
.
If you opt to use the Docker approach, you will need to change all invocations
of jtd-fuzz
in this README from:
To:
# To have jtd-fuzz read from STDIN, run it like so:
# To have jtd-fuzz read from a file, run it as:
# or, if file.json is in your current directory:
Usage
Basic Usage
To invoke jtd-fuzz
, you can either:
- Have it read from STDIN. This is the default behavior.
- Have it read from a file. To do this, pass a file name as the last argument
to
jtd-fuzz
.
jtd-fuzz
reads in a single JSON Typedef schema, and will output, by default,
an infinite stream of examples. For example, this will output an infinite
sequence of random JSON data:
|
If you'd like to have jtd-fuzz
output an exact number of results, use -n
:
|
Or, to have jtd-fuzz
read from a file:
Advanced Usage: Providing a Seed
By default, jtd-fuzz
will generate different output every time:
| ; |
null
If you'd like to get consistent output from jtd-fuzz
, or be able to reproduce
its output, you can use the -s
option to provide a seed to its internal
pseudo-random number generator. For the same seed and schema, jtd-fuzz
will
output the same data every time:
| ; |
48
48
The -s
option takes an integer between 0 and 2^64 - 1.
Seeding jtd-fuzz
can be useful if you're using jtd-fuzz
to do automated
testing against a system. Your automated testing system can pass jtd-fuzz
a
randomly-generated seed, and if the automated tester finds a seed that reveals a
bug, it can output the seed it used. That way, developers can re-use that seed,
and try to reproduce the issue locally.
Note that jtd-fuzz
is only guaranteed to produce consistent output if you use
the same seed, schema, and version of jtd-fuzz
. Different versions on
jtd-fuzz
may output different results, even if you give them the same seed and
schema.