Dicetest
Dicetest is a framework for writing tests with pseudorandom generated test data.
Status of this crate
The author does not consider this crate as stable yet.
Simple example
Here's an example of a broken sort function tested with Dicetest:
Running cargo test
produces the following output:
The test failed after 36 passes.
# Config
- seed: 795359663177100823
- start limit: 0
- end limit: 100
- passes: 1000
# Counterexample
- run code: "ABIDje/+CYVkmmCVTwKJ2go6VrzZWMjO2Bqc9m3b3h0DAAAAAAAAAA=="
- limit: 3
- hints:
- unsorted: [255, 252, 131]
- sorted: [255, 131, 252]
- error: assertion failed: is_sorted
You can rerun the counterexample by setting a environment variable:
DICETEST_DEBUG=ABIDje/+CYVkmmCVTwKJ2go6VrzZWMjO2Bqc9m3b3h0DAAAAAAAAAA== cargo test
Alternatives
- Write down your test data and use a loop.
- Use the crate
quickcheck
. - Use the crate
proptest
.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.