Here is a program that I think should exist: When an application is running, it automatically records all calls to all methods. It then creates a test based on each call. (Such a test might be called a unit test, but I'm not doing so here because there is an issue of capturing state.)
For a typical app, this program would generates thousands and thousands of tests automatically after just a few uses of the program.
Does this program exist? If not, why not? Is there a program that does something close to this?
A more sophisticated version of this program would do the following:
- It would recombine parameters from multiple calls to create a new test. For example: A method is called with (1,A) and (2,B). This utility would generate unit tests that call the method with (1,B) and (2,A).
- It would perturb the calls to create new tests. For example: A method is called with two integers (1,2). This utility would create tests that call the method with (0,2), (1,3), (0,3), etc.
I appreciate the fact that some of the tests generated by such a utility would be incorrect. Nevertheless, I think such a utility would be extremely useful, particularly when testing legacy apps.