Script the pain away

I have a test suite that takes one minute to run.

I run it, wait 20 seconds, get bored and go do something else. I finally remember what I was doing about 5-15 minutes later and check the test, but by then I’ve often lost the context of what I was testing and why! This is a problem for all devs, but ADHD makes it a much bigger problem because I struggle to find focus on a minute-by minute basis, so when I’ve fought  to get focused on a task (and won) the last thing I want is for the task to encourage me to get distracted. 

I’ve found something that works really well for me here – I made a shell script that runs the test and pops up a dialog box to tell me that it’s done. It even asks if I want to go look at it!
ytest(){
    yarn test
    SURETY="$(/usr/bin/osascript -e 'display dialog "Yarn TEST is finished. Go to terminal?" buttons {"Yes", "No"} default button "Yes"')"
    if [ "$SURETY" = "button returned:Yes" ]; then
        osascript -e 'tell application "iterm" to activate'
    fi
}

If the pop up is too aggressive then here is a version to just display a notification

ytest(){ 
    yarn test 
    SURETY="$(/usr/bin/osascript -e 'display dialog "Yarn TEST is finished. Go to terminal?" buttons {"Yes", "No"} default button "Yes"')" 
    if [ "$SURETY" = "button returned:Yes" ]; 
        then osascript -e 'display notification "Your test has finished." with title "Always waiting on 'Yarn Test'" subtitle "The hard part is over."' 
    fi 
}

I stick these scripts in my ~/.zshrc file and they are available inside my terminal after (restarting it) by typing ytest The specifics here might not fit into your type of work, but I think the general concept is pretty worthwhile – if something is making it artificially hard to keep your concentration look for tools that can get you back on task. Removing friction makes it easier to stay on task, which makes it more likely you will make more progress (if not finish!).

It’s very important that I get the test suite run time down to something shorter than my attention span

Another TOTALLY VALID approach to this problem (long tests causing lost focus) is digging into why the test suite takes so long. It’s very important that I get the test suite run time down to something shorter than my attention span, but this is also a great quality of life and productivity gain in terms of other developer time and attention saved. Much like documentation as a superpower – this is one of those things that will reap huge benefits across the org and can turn an adaptation to avoid a vulnerability into a superpower that enables your entire company.

Leave a comment

Your email address will not be published. Required fields are marked *