hypothesis-jsonschema icon indicating copy to clipboard operation
hypothesis-jsonschema copied to clipboard

New feature: command-line interface

Open Zac-HD opened this issue 1 year ago • 0 comments

It occurs to me that having a jsonschema and wanting to test something is by no means limited to projects using Python, and we can pretty easily provide a useful tool or two. Specifically:

hypothesis json SCHEMA --num=100 --seed=0: write NUM instances conforming to SCHEMA to standard out, one line each. The schema can be provided inline, or as a filename. We use the obvious translation to a test under the hood, no database, and bump up max_examples so that we can ensure every line is unique.

hypothesis json SCHEMA --num=100 --script=test.sh: write each example to testcase.json, execute ./test.sh testcase.json, shrink to minimal failing example as usual. Key database off the schema itself, but not the test script; NUM is the max_examples setting directly for this one. The classic fuzzer interface.

Zac-HD avatar Mar 09 '24 06:03 Zac-HD