Luke Gorrie (lukego) wrote,
Luke Gorrie

Regression tests and regtest.erl

My new favourite kind of program is one that tests whether two big and complex programs are substantially equivalent. With tools like this I can take one big and complex program, rewrite parts of it for clarity, and then have confidence that my new version preserves the original behaviour. I think this is much simpler than testing for correctness.

I wrote one particular Erlang regression test program called regtest.erl along these lines. The idea is first to execute a large and complex program on a lot of inputs and to record what happens in log files, then to test the logs from separate runs for equivalence. If the consequences in the logs are the same before and after my hacking then I know the overall behaviour is substantially the same.

Lately I write small programs like this any time I want to rewrite important code that has no explicit test suite. I'm finding it very useful!

Tags: erlang, hacking, testing
  • Post a new comment


    default userpic
    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.