Skip to content

Commit 88834fb

Browse files
authored
docs: Add a short quickstart to readme (#96)
1 parent 5b3fc33 commit 88834fb

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

README.md

+44-10
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,54 @@ fuzz and property testing front-end for Rust
1111

1212
A copy of the Bolero Book can be found here: http://camshaft.github.io/bolero
1313

14-
## Installation
14+
## Quick Start
1515

16-
`bolero` is on `crates.io` and can be added to a project like so:
16+
1. Install subcommand and add a dependency
1717

18-
```toml
19-
[dev-dependencies]
20-
bolero = "0.8"
21-
```
18+
```console
19+
$ cargo add --dev bolero
20+
$ cargo install -f cargo-bolero
21+
```
2222

23-
`bolero` also provides a CLI program to execute fuzz tests, [`cargo-bolero`](https://crates.io/crates/cargo-bolero). It can be installed globally with cargo:
23+
2. Write a test using [`bolero::check!`](https://docs.rs/bolero/latest/bolero/macro.check.html) macro:
2424

25-
```bash
26-
$ cargo install -f cargo-bolero
27-
```
25+
```rust
26+
pub fn buggy_add(x: u32, y: u32) -> u32 {
27+
if x == 12976 && y == 14867 {
28+
return x.wrapping_sub(y);
29+
}
30+
return x.wrapping_add(y);
31+
}
32+
33+
#[test]
34+
fn fuzz_add() {
35+
bolero::check!()
36+
.with_type()
37+
.cloned()
38+
.for_each(|(a, b)| buggy_add(a, b) == a.wrapping_add(b));
39+
}
40+
```
41+
42+
3. Run the test with `cargo bolero`
43+
44+
```console
45+
$ cargo bolero test fuzz_add
46+
47+
# ... some moments later ...
48+
49+
======================== Test Failure ========================
50+
51+
Input:
52+
(
53+
12976,
54+
14867,
55+
)
56+
57+
Error:
58+
test returned `false`
59+
60+
==============================================================
61+
```
2862

2963
### Linux Installation
3064

0 commit comments

Comments
 (0)