Laravel : "10"
php : "8.3"
phpunit: "10.1"
# SetUp Unit Test Laravel
1. Environment
When running tests, Laravel will automatically set the configuration environment to testing because of the environment variables defined in the phpunit.xml file. Laravel also automatically configures the session and cache to the array driver so that no session or cache data will be persisted while testing.
You are free to define other testing environment configuration values as necessary. The testing environment variables may be configured in your application's phpunit.xml file, but make sure to clear your configuration cache using the config:clear Artisan command before running your tests!

2. Adding Tests
To create a new test case, use the make:test
Artisan command. By default, tests will be placed in the tests/Feature
directory:

If you would like to create a test within the tests/Unit
directory, you may use the --unit
option when executing the make:test
command:

3. Running Tests
In addition to the phpunit command, you may use the test Artisan command to run your tests. The Artisan test runner provides verbose test reports in order to ease development and debugging:

4.Reporting Test Coverage
When running your application tests, you may want to determine whether your test cases are actually covering the application code and how much application code is used when running your tests. To accomplish this, you may provide the --coverage option when invoking the test command:

Reporting test coverage feature requires Xdebug or PCOV.
5.SetUp Xdebug
When running your application tests, you may want to determine whether your test cases are actually covering the application code and how much application code is used when running your tests. To accomplish this, you may provide the --coverage
option when invoking the test
command:

Edit Configuration X debug
open xdebug.ini on /etc/php/mods-available/xdebug.ini

Enforcing a Minimum Coverage Threshold
You may use the --min
option to define a minimum test coverage threshold for your application. The test suite will fail if this threshold is not met:
