I've noticed that when I write Javascript tests (and am in a rush), I often just call a bunch of functions with (semi-)randomly chosen arguments, check what return values / changed state I get and codify that in a test suite using asserts so that when I want to refactor later I can catch some bugs. It's obviously not the ideal way to write tests but it's better than nothing.<p>I was wondering if I could automate the process by writing a tool that would extract all exported functions from a module, call them with randomly generated arguments and save return values and/or changed state. The tool could then generate a test suite using that information. The tool could also be used to quickly add tests to third party libraries.<p>Of course this tool would generate "dumb" tests with raw data but the intent here is not to offer an alternative to human written tests but rather to offer an alternative to no tests at all.<p>The concept could be applied to other languages as well.<p>Does such a tool already exist?<p>Am I overlooking some critical issue?<p>Do you think such a tool would be useful?
There is something called quick_check.js [0] that looks similar to what you want. It's inspired by Haskell's QuickCheck library [1].<p>[0] <a href="https://github.com/gampleman/quick_check.js" rel="nofollow">https://github.com/gampleman/quick_check.js</a><p>[1] <a href="https://wiki.haskell.org/Introduction_to_QuickCheck1" rel="nofollow">https://wiki.haskell.org/Introduction_to_QuickCheck1</a>