Hello! I looked through a couple of blog posts on your website and it sounds like this tool helps with unit testing. Can you please provide additional info on this?
Hi Praveen. Mayhem is a little different from unit testing, but the principle for driving tests is the same. Unit tests test for some known behavior, i.e. if you have the factorial function
fact(int x) that computes the factorial of some number, a proper unit test would be something along the lines of
assert(fact(3) == 6).
If you wanted to write a unit test for every possible input of your factorial function, you would have to write an infinite amount of unit tests. But what about unexpected inputs? That is, what is
fact(NULL)? or some randomly generated string? What if your implementation of fact doesn’t handle integer overflow? Fuzz testing helps with this problem by exploring the problem input space (the function in question) and attempts to generate test cases automatically that uncover new code paths. Mayhem helps you solve the infinite space problem by reducing inputs to those that actually matter (i.e. touch new code paths), and tell you which inputs causes issues in the code, where the issues were found, and what input you can use to reproduce the failure.