Home Practical Testing Tips

Enter a search term to find articles.

Practical Testing Tips

Some small and practical testing tips from yours truly.

  1. 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;
  2. 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
  3. 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!

Marvin Quezon

Full Stack Web Developer
Marvin Quezon · Copyright © 2024 · Privacy · Sitemap