Some small and practical testing tips from yours truly.
-
If your tests are not hitting the database, remove the
use RefreshDatabase
statement. This will greatly speed up your test as it won't run migrations.class ExampleTest { use RefreshDatabase; ... }
-
If you want to see details when you run your tests but don't want to use 3rd party printer package, you can utilize the
--testdox
flag in PHPUnit. This flag will show which test class and method is currently running.phpunit --testdox
-
Getting overwhelmed with too many errors when you run a group of tests or your entire test suite? Use the
--stop-on-failure
flag in PHPUnit. This will cause the test to stop on first occurence of failure.phpunit --stop-on-failure
Happy testing!