PHP Unit Test Explorer With Laravel Sail
What is PHP Unit Test Explorer
Before we discuss in deep, i want to explain the standard definition. PHP Unit Test Explorer is one of extensions in visual studio code. You can search in extension menu and install it.
After installed, you can find it on sidebar. It has test tube icon.
Laravel Sail
Laravel sail is one of laravel tools for easy and consistent development. Under the hood, it uses docker and docker compose. One advantage using sail is we don't need to setup bunch of php and web server configuration. It was already handled by sail. We just need to run docker compose command or via sail command. You can learn more detail about how sail works in Laravel documentation here.
What if we want to implement TDD in Laravel?
As developer, we need to make sure our code run well. So, we need to test it by implementing TDD. Luckily, Laravel support TDD by default. You can run artisan command to generate test file. In the newest version, Laravel supports phpunit and pest configuration.
The Configuration
If you want to use PHP Unit Test Explorer with sail, there are several configuration to follow. First, you have to open extensions settings by click gear icon in bottom right corner. It will show setting configuration for PHP Unit Test Explorer.
You need to fill it like screenshot below
if you prefer json configuration, you can copy this json settings
{
"phpunit.command": "./vendor/bin/sail bash -c",
"phpunit.paths": {
"$workspaceFolder": "/var/www/html"
}
}
Comments
Post a Comment