Devnotes > Quick go test cycle with reflex
While you are working on some piece of code, it is nice to have some feedback about whether you broke or fixed something by running the relevant unit tests. To automate this I usually have a terminal window open with the following command:
$ reflex -r '\.go$' -- sh -c 'clear && go test -v ./web/model --run TestEvent'
reflexis a small utilty that watches for changes on the file system.
-rindiates that it should only watch changes in files that satisfy the following regex pattern.
'\.go$'the regex tells to only watch change in go files.
--signifies the end of reflex options.
shshell to interpret the command we want to run.
shto listen to commands entered after, not to standard input.
clearfirst clear the terminal window.
go testrun the test in verbose mode.
-vwill produce a more verbose output with PASS/FAIL for each test and the output fom
./web/modelonly test files in the
-run TestEventonly run test with names that satisfy the regext
reflex is only triggered by changes on the filesystem. After entering the command, nothing happens until you save a