You can often shorten Laravel test runs by finding slow tests, trying parallel execution, and reusing cached configuration—but the official documentation does not establish a general 3× speedup for stancl/tenancy. Treat 3× as a result to reproduce, not an expected outcome: measure the same suite before and after each change, and verify tenant isolation and test correctness.
How to find what is slowing your tests
Start with a measurement rather than assuming tenancy initialization, migrations, or Laravel’s application boot is the main bottleneck. Laravel’s test profiling option lists the ten slowest tests:
php artisan test --profile
Use the profile to identify candidates for investigation. A slow test may be doing costly database work, repeated setup, or something unrelated to tenancy. Profiling identifies where to look; it does not itself make the suite faster.
How to run Laravel tests in parallel with stancl/tenancy
Laravel runs tests sequentially by default. Its parallel testing support uses ParaTest. Install it as a development dependency, then run the suite in parallel:
#1 Best Overall
-
Install ParaTest:
composer require brianium/paratest --dev. -
Run the tests:
php artisan test --parallel. -
To control the number of workers, specify a process count, for example
php artisan test --parallel --processes=4. Without this option, Laravel uses the machine’s available CPU cores.
Laravel creates and migrates a separate test database for each process, using a process token in the database name. It also documents ParallelTesting setup and teardown hooks for resources that need to be prepared or cleaned up per process. Some Pest and PHPUnit options may not be available in parallel mode.
Check every shared resource, not just the central test database
Per-process central databases do not automatically guarantee isolation for every tenant resource in a multi-database application. Check how your tests handle tenant databases, filesystem paths, Redis or other cache state, queues, and any other resource that workers might share. Add process-aware setup through Laravel’s hooks where needed, and validate the approach against your application’s tenancy configuration.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Rank #3
Parallelism can reduce wall-clock time, but it also uses more resources and may expose shared-state assumptions that sequential runs conceal. Keep it only if repeated runs show a useful improvement and the tests remain reliable.
Account for stancl/tenancy’s testing requirements
The stancl/tenancy v3 testing guide distinguishes central-app tests from tenant tests. Central-app tests can use ordinary Laravel testing patterns. Tenant tests should create a tenant and initialize tenancy, commonly in setUp() or a dedicated tenant test case.
Rank #4
Multi-database automatic mode has database-testing limits
In multi-database tenancy with automatic mode, the guide says in-memory SQLite (:memory:) and Laravel’s RefreshDatabase trait are not supported because tenancy switches the default database. Do not adopt those shortcuts without first checking your project’s actual tenancy mode. The v3 quickstart describes multi-database tenancy and domain identification as the default implementation while allowing other configurations.
Fake events selectively
The package relies heavily on events, and broad use of Laravel’s Event::fake() can interrupt tenancy initialization or related processes. When a test needs to fake events, fake only the relevant event classes, for example Event::fake([MyEvent::class]), so required tenancy events can still run.
Recommended Free Tools
Best Value
Try cached configuration when repeated loading is costly
Laravel documents WithCachedConfig for building configuration once and reusing it across tests in a run. This targets repeated configuration loading: the framework boots for each test method and otherwise loads configuration files at each test start. Check compatibility with your test setup, then compare timings on the same suite; the documentation does not promise a particular speedup.
Compare the optimization options on your own suite
| Option | What it changes | What to verify |
|---|---|---|
Profiling with --profile |
Identifies the ten slowest tests; it does not change execution speed. | Whether the tests it identifies contain an optimizable bottleneck. |
| Parallel execution | Runs tests across processes and may reduce wall-clock time. | Tenant and other shared-resource isolation, worker resource use, and compatibility with test options. |
WithCachedConfig |
Reuses configuration across tests in a run. | Compatibility with the project’s setup and measured runtime change. |
Laravel and stancl/tenancy document these features and constraints, not their relative performance or a universal ranking. Compare them using runtime on the same suite, correctness and tenant isolation, implementation and CI cost, compatibility with your database and tenancy mode, and repeatability on local machines and CI.
How to measure whether you reached 3×
The official materials cited here provide no project-specific before-and-after timings or benchmark conditions establishing a 3× improvement. To report a multiplier credibly, record a baseline and repeat the same test selection under the same conditions. Change one factor at a time, then rerun and check that the result is correct as well as faster.
For comparisons, record the commit and dependency lock state, PHP runtime, Laravel and database versions, hardware or CI worker, cache state, process count, and exact test command. Report the measured result with those conditions and limits; a result on one suite or machine is not a general expectation.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Fix the driver behind crashes, sound loss and screen glitches3Repair Windows errors before they cause bigger problemsPackage contributors should also distinguish their local test environment from a locked application setup. The tenancy repository’s testing instructions require Docker, Docker Compose, and Bash; its ./test script runs in Docker containers and uses the most recent dependency versions by default. Those choices can make timings differ from runs against an application’s locked dependencies.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

