Laravel tenancy package tests optimized for 3x speed improvement
A developer found a method to significantly accelerate test suites for Laravel applications using the stancl/tenancy package. The optimization involves creating a single tenant and its database per test file rather than per individual test. This approach reduces the time-consuming processes of database creation and migration that occur with each tenant. Testing on 111 tests showed execution time dropping from 87 seconds to 26 seconds, a roughly 70% reduction. The technique uses transactions and careful cleanup to manage tenant data across multiple tests within a file.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in