Setting Up PHPUnit in PHPStorm
March 4 2015, 6:57pm
This is more so just notes for how I got PHPUnit running in PHPStorm for my project. There's probably a more optimal way to set this up but this works for now.
Tell PHPStorm to Use Composer's Copy of PHPUnit And Set Default Config
Preferences > PHPUnit
Docs: Loading PHPUnit with Composer.
Edit PHPUnit Configuration to use your custom config file
Run > Edit Configurations
Click the plus (+) sign and select PHPUnit.
Docs: Run/Debug Configuration: PHPUnit.
You can now right click (or use the keyboard shortcut) on files or folders and run unit tests.
Note: It may prompt you to setup the PHP Interpreter, open up terminal and type which php
to find out where the php version is that your using then paste that in as the interpreter location (related docs).
Results
PHPStorm now tells how much unit test coverage you have beside each file/folder in the navigation tree and a Coverage panel should slide in from the right.
Setup PHPUnit to Run in Vagrant
You might need to run your phpunit inside Vagrant for some reason, follow this guide to do so.
- Tags:
- phpunit
- phpstorm
- unit testing