Summer Sale! All accounts are 50% off this week.

tetthys's avatar

Any features or tips to reduce testing database concurrency issues for parrallel testing?

I want to be clear about this.

User::factory()->make() is not enough.

0 likes
1 reply
Tray2's avatar

The make method does not store anything in the database, it just creates an object that you can store in the database. If you use create on the other hand it will store it in the database.

The important thing when testing the database is to never ever assume that a id has a certain value. You always need to fetch the record from the database to get the value.

And parallell testing uses different databases for each thread.

And I also recommend using this package.

https://packagist.org/packages/plannr/laravel-fast-refresh-database

Please or to participate in this conversation.