I use characterisation testing all the time, in a perhaps unusual application: Checking the behaviour of "Page Objects" (classes used to model the application-under-test in GUI-level automated testing) when the application-under-test has changed. That's right: Automated [characterisation] tests for my automated [GUI] tests! It makes GUI testing oh so much easier to maintain. I wrote it up here: https://david.rothlis.net/pageobjects/characterisation-tests
Using `make` and `git diff` for a simple and powerful test harness
21–30 of 48 posts
Re: Using `make` and `git diff` for a simple and powerful test harness
#22Its not as slick or concise as the solution proposed here, but it shows that the approach is viable for medium-large projects.
Re: Using `make` and `git diff` for a simple and powerful test harness
#23One trick I found helpful was using JSON to serialize test results instead of unstructured plain text.
Test results stored as JSON are much easier parse and therefore process. You can quickly whip up programs that verify the tests satisfy invariants, diff the tests and filter out expected test changes from unexpected test changes.
Re: Using `make` and `git diff` for a simple and powerful test harness
#24This technique is also known as characterisation testing, golden-master testing, snapshot testing, and probably other names too. I recommend looking into https://approvaltests.com/ (already mentioned by another commenter). I use characterisation testing all the time, in a perhaps unusual application: Checking the behaviour of "Page Objects" (classes used to model the application-under-test in GUI-level automated test…
Re: Using `make` and `git diff` for a simple and powerful test harness
#25Re: Using `make` and `git diff` for a simple and powerful test harness
#26This technique is also known as characterisation testing, golden-master testing, snapshot testing, and probably other names too. I recommend looking into https://approvaltests.com/ (already mentioned by another commenter). I use characterisation testing all the time, in a perhaps unusual application: Checking the behaviour of "Page Objects" (classes used to model the application-under-test in GUI-level automated test…
This would require auto-mocking of all subsystems to prevent side-effecting functions from sending email & SMSes.
Re: Using `make` and `git diff` for a simple and powerful test harness
#27Re: Using `make` and `git diff` for a simple and powerful test harness
#28I've used a similar technique to test, generating an expected output, actual output and then diff them. One trick I found helpful was using JSON to serialize test results instead of unstructured plain text. Test results stored as JSON are much easier parse and therefore process. You can quickly whip up programs that verify the tests satisfy invariants, diff the tests and filter out expected test changes from unexpect…
This aspect of expected and unexpected test changes is even more important than the diff part in my opinion. It allows you add failing tests immediately once you get the bug report and you notice if you fix something accidentally.
Re: Using `make` and `git diff` for a simple and powerful test harness
#29Fun. The rwildcard function here rwildcard = $(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $2,$d)) is very similar to one I wrote in 2011 ( https://blog.jgc.org/2011/07/gnu-make-recursive-wildcard-fun... ): rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d)) The only difference is that I wanted to be able to use * in the pattern rather than % (hence the subst).…
I believe it is a direct descendant of yours, which I’ve used from time to time over the years. I just didn’t feel the need to support *, % was enough for me. Thanks for all the stuff you’ve written about Make: I’ve enjoyed reading quite a lot of it!
For those who don't know, here's a list of stuff I've written over the years.
https://blog.jgc.org/2013/02/updated-list-of-my-gnu-make-art...
And the hard copy version: https://nostarch.com/gnumake
PS I really like the layout of your blog.
Re: Using `make` and `git diff` for a simple and powerful test harness
#30I've used a similar technique to test, generating an expected output, actual output and then diff them. One trick I found helpful was using JSON to serialize test results instead of unstructured plain text. Test results stored as JSON are much easier parse and therefore process. You can quickly whip up programs that verify the tests satisfy invariants, diff the tests and filter out expected test changes from unexpect…
When I did it, we skipped the Make part and reinvented it in Python: https://github.com/libfirm/sisyphus This aspect of expected and unexpected test changes is even more important than the diff part in my opinion. It allows you add failing tests immediately once you get the bug report and you notice if you fix something accidentally.
I've been using cram (also written in Python) for a private project and been mostly happy with it: https://bitheap.org/cram/