(Git) Diff for Testing and Debugging Scripts

Has anyone ever used diff (e.g git diff) to compare log files for testing and debugging automation scripts? For example, diff the log output from a refactored script against a validated original copy?

Seems like it could be a really powerful and efficient way of validating new code.

Yes, you can potentially do this. Of course, you’d have to strip out things like the timestamps etc, but if you knew what you expect in the trace file then you can compare against that (whether or not via diff tools or regex is better is another question).

I think I’ve asked on this forum before about automated testing of automation methods. It isn’t too much of a stretch to extend your idea to also automating input of python generated (or otherwise) input files to test different scenarios en masse. This has worked well for me in the past.

FWIW, I wouldn’t use git diff though, you (probably) wouldn’t want to commit your trace files into your version history. Normal diff tools would be useful though.

1 Like

Here is an example of the tool I just made to implement this