If you use SublimeText as your editor, you can automatically visualize code coverage using the Sublime Code Coverage package and the Sublime Build on Save package.
-
Install both Sublime packages.
-
Go to Preferences > Settings - User and add the following settings:
"binary_file_patterns": [ "vendor/*" ]
-
Create a file in the root of the L4withSentry project called
l4withsentry.sublime-project
and put the following in it, replacing/usr/local/php5/bin
with your php path.
{
"folders":
[
{
"path": "./"
}
],
"settings":
{
"filename_filter": "\\.(php|.html.blade)$",
"build_on_save": 1
},
"build_systems":
[
{
"name": "PHPUNIT",
"path": "/usr/local/php5/bin",
"cmd": [
"$project_path/vendor/bin/phpunit",
"--coverage-clover=$project_path/build/logs/clover.xml",
"--configuration=$project_path/phpunit.xml"
]
}
]
}
- Restart Sublime Text
- Reopen L4withSentry using these steps:
- Go to Project > Open Project...
- Select the
l4withsentry.sublime-project
that you created above. - Manually build the project
- Tools > Build System, make sure PHPUNIT is selected
- Click Tools > Build to run phpunit against the project and generate initial coverage files.
- You should now be able to open app/controllers/UserController.php and visually see the what code is covered by tests and what code is not.
Note: If a file is not referenced at all in a test, then it will not have any visual indicators in it. To start seeing visual indicators, write a test that covers some part of this file.