proptest-rs / proptest

Hypothesis-like property testing for Rust
Apache License 2.0
1.63k stars 152 forks source link

Example of using external "faking"? #431

Closed cylewitruk closed 3 months ago

cylewitruk commented 4 months ago

I've only been looking for a couple of hours but I seem to find it difficult to find examples of how to provide my own implementation of faked complex types? i.e. in the context of using fn something(x in any::<y>()). I currently have a number of faked implementations using the fake crate, but I'm struggling to figure out how I can use these together with proptest, if at all possible or feasible?

cylewitruk commented 3 months ago

I ended up migrating everything to proptest strategies and dropping fake -- so this question can be closesd 😊

matthew-russo commented 3 months ago

Thanks for the update. I had started looking in to fake but hadn't built enough of an understanding to answer properly. I think it would have been quite difficult/non-intuitive to build an integration since it seems like the models of value generation are quite different. If you run in to any issues, still want a tighter integration with fake, or find any missing features, please open a new issue describing them.

cylewitruk commented 3 months ago

Thanks for the update. I had started looking in to fake but hadn't built enough of an understanding to answer properly. I think it would have been quite difficult/non-intuitive to build an integration since it seems like the models of value generation are quite different. If you run in to any issues, still want a tighter integration with fake, or find any missing features, please open a new issue describing them.

The only thing I can think of is making the underlying Rng instance available as fake has a Faker.fake_with_rng() method. But I don't know if the tests would still be deterministic if that were called from within a proptest?