What's the tip/trick here?
How to speed up in memory db tests with fake seeds
Hey, I was wondering. How could I speed up my tests? I have in memory sqlite databse with one table and one small and simple seed file using Faker library. It is generating 10 records in a foreach range loop with 7 calls to faker to get the data.
The problem is that when I migrate + seed this databse it took Time: 8.05 seconds, Memory: 22.25Mb which is I believe too long for such as simple seed (have just one simple assertion for now). How long would it take later when I will be seeding products, categories and so on? Since I am using in memory database I need to migrate and seed it before every test.
The seeder uses User::create() method. I've noticed that when I first build the array in a loop and then used DB::table('users')->insert($fakeObjects); it took Time: 1.93 seconds, Memory: 22.25Mb which is significantly better. However with DB table insertion I have to specify things like created_at and other auto generated stuff and I don't like to repeat this step every time.
How are you guys doing it? Is there some simplier solution?
Please or to participate in this conversation.