4 ms·
If you have any examples of this I'd love to see them. Are you just doing a random pick of X possible actions N times?
by new_stranger 5y ago
If you have any examples of this I'd love to see them. Are you just doing a random pick of X possible actions N times?
- osi 5y agoWe're using jqwik's stateful testing to achieve this, https://jqwik.net/docs/current/user-guide.html#stateful-testing https://jqwik.net/docs/current/user-guide.html#stateful-test... It's essentially as you described.
- josephg 5y agoSure - here's a simple fuzzer from a rope (fancy string) library I wrote a few years ago back when I was still learning rust. (Don't judge me!): https://github.com/josephg/skiplistrs/blob/master/tests/test.rs#L356-L414 https://github.com/josephg/skiplistrs/blob/master/tests/test... In a loop it simply randomly decides whether to insert, delete or replace some text, and after any action checks that the state is valid (In this case via a call to check2()). You can go way deeper with this sort of thing if you want, with more complex models, random item generation and simplifiers to help pare down problems to simple test cases. And you can have more complex state - for example, where you also track interaction between multiple items. For example, if your state is a few users, and you also track one user paying another user and verify the total balance across all users is unchanged. But you don't need to go deep for fuzz testing to be worthwhile. Even something as simple as this little loop is a remarkably effective bug finder.