PhpStorm Testing Workflow
Jun 10, 2020 1:30 PM (6 months ago)

# PhpStorm Testing Workflow

In order to reduce the friction to the minimum so that I can get on with my work, I streamline as much as possible every workflow I end-up repeating several times during the day.

Testing was one of the workflows I used to loathe, with the constant switching to the console or terminal, and having to run custom phpunit commands filtering by the title to get only one single test running.

# Workflow

One of my favorite things to do to improve this workflow is to key bind PhpStorm's Run Context Configuration to ⌘T, so that every time I bring the cursor within the test, I can run that single test by pressing ⌘T.

Just make sure that PhpUnit (or whatever testing suite you are using) is configured within PhpStorm first.

PhpStorm Testing Workflow

This is achieved by simply key-binding ⌘T to Run Context Configuration in PhpStorm.

Open PhpStorm's Preferences ⌘, and start typing keymap in the search (1), then search for run context configuration within the keymaps (2), and bind whatever key combination you prefer to it.

PhpStorm Keymap Preferences

That's it!

I have also a very similar workflow in VS Code, but you need a plugin for it.


I bind also Rerun to ⌘ + Shift + T to re-run the last run test, so that when you are outside the test class, doing the modifications in the target class to make the test pass, you can re-run the test from there without needing to going back to the test class.