Back

Hi guys!
I have one question about unit tests:
How do you guys do it when testing, do you create a db just for testing?

#Laravel #phpunit

2

289

In response to @hugomatheuss

I use a test DB (my_app_name_test) with the Illuminate\Foundation\Testing\RefreshDatabase trait. I use the same DB type/engine as production. I consider a Unit test anything that tests a single class. If that class uses the DB or other classes, so be it. I am not mocking them :) Keep it simple, do what works for you.

Feature tests for me are typically HTTP request/controller tests which truly touch a whole bunch of stuff and is testing more of the wiring of everything together. Integration tests for me are tests that test third party services. They actually hit the third party service's API. I have them excluded from my default test suite using defaultTestSuite="Unit,Feature".

89

  • No matching results...
  • Searching...

/ 1000