In a recent automation work I’ve been asked to take part in, running a single test safely, according to peers, generally follow a three-step process:
- Delete existing feature files:
rm -rf *.feature
- Create updated feature files:
PROJECT_DIRECTORY=../<dir> APP=<app> TEST=automated ruby create_tests.rb
, where app is the name of the app you want to test - Run the desired specific test:
cucumber --tags @<tag>
This means I have to re-run these three steps over and over for every single test I want to review. That can get tiring easily, especially if I have to re-type them repeatedly, or even if I copy-paste. Using the arrow keys in the terminal helps, but sometimes commands can get lost in the history and then it becomes a bit of a hassle to find them.
There should be a way for me to run an automated check I want to review, given just the app name and the test tag. It would be nice if I can run a specific test using a shorter command but still following the same process as provided.
I decided to set aside a little bit of time to write a personal script, and used Makefile because I’ve had experience with that before.
My personal short command for running a test: make test app=<app> tag=<tag>
And here’s what the script looks like, which runs the known commands step-by-step plus displays some information on what’s currently happening:
Now I won’t have to worry about remembering what commands to type in as well as the sequence of the commands. I can give more focus on actually reviewing the test itself, which is what’s more important.