<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/feixtkjkb" -->

---
title: How We Made Our Multi-Tenant Tests 25x Faster with...
description: A multi-tenant Laravel app using stancl/tenancy had painfully slow tests: 1-3 seconds per test, 5 minutes for a full suite, and 30 minutes on GitHub Actions....
canonical: https://daily.dev/posts/feixtkjkb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How We Made Our Multi-Tenant Tests 25x Faster with Stancl Tenancy Package | daily.dev
og:description: A multi-tenant Laravel app using stancl/tenancy had painfully slow tests: 1-3 seconds per test, 5 minutes for a full suite, and 30 minutes on GitHub Actions....
og:url: https://daily.dev/posts/feixtkjkb
og:image: https://api.daily.dev/og/posts/fEixtkjkb.png
og:image:alt: Post cover image
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How We Made Our Multi-Tenant Tests 25x Faster with Stancl Tenancy Package

**[Laravel Dev](https://daily.dev/sources/laraveldev)** · [@danielpetrica](https://daily.dev/danielpetrica) · 3 upvotes · 0 comments

## Summary

A multi-tenant Laravel app using stancl/tenancy had painfully slow tests: 1-3 seconds per test, 5 minutes for a full suite, and 30 minutes on GitHub Actions. The fix was wrapping each test in database transactions across both the central and tenant databases, rolling back after each test instead of recreating and migrating the tenant database every time. Two custom traits were built: ManagesMultipleDatabaseTransactions (handles transaction lifecycle across multiple DB connections) and InitializesTenancy (creates the tenant and runs migrations only once per suite). The result: single tests dropped to ~0.04 seconds, full suite to ~10 seconds, and CI to ~3 minutes — a 25x speedup.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.dasun.dev/blog/how-we-made-our-multi-tenant-tests-25x-faster-with-stancl-tenancy-package>

## Similar posts on daily.dev

- [Don’t just attend KubeCon \+ CloudNativeCon, Merge Forward your experience\!](https://daily.dev/posts/don-t-just-attend-kubecon-cloudnativecon-merge-forward-your-experience--l0rpp73x8) · CNCF · 1 upvotes · 0 comments
- [Announcing H2 2026 KCDs](https://daily.dev/posts/announcing-h2-2026-kcds-m96goajm1) · CNCF · 1 upvotes · 0 comments
- [Two months of Open Community Groups](https://daily.dev/posts/two-months-of-open-community-groups-asf52zhbs) · CNCF · 0 upvotes · 0 comments
- [CNCF Unveils Schedule for KubeCon \+ CloudNativeCon Europe 2026](https://daily.dev/posts/cncf-unveils-schedule-for-kubecon-cloudnativecon-europe-2026-ikhcoa5cb) · CNCF · 2 upvotes · 0 comments
- [CNCF Debuts KubeCon \+ CloudNativeCon Japan 2026 Schedule](https://daily.dev/posts/cncf-debuts-kubecon-cloudnativecon-japan-2026-schedule-xp5pyudub) · CNCF · 1 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#laravel](https://daily.dev/tags/laravel), [#multi-tenancy](https://daily.dev/tags/multi-tenancy)

[View this post on daily.dev](https://daily.dev/posts/feixtkjkb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/feixtkjkb","headline":"How We Made Our Multi-Tenant Tests 25x Faster with Stancl Tenancy Package","text":"Shared: How We Made Our Multi-Tenant Tests 25x Faster with Stancl Tenancy Package","url":"https://daily.dev/posts/feixtkjkb","datePublished":"2026-03-02T12:56:54.121Z","dateModified":"2026-03-02T12:56:54.124Z","author":{"@type":"Person","name":"Daniel, Petrica Andrei-Daniel","url":"https://daily.dev/danielpetrica","image":"https://avatars.githubusercontent.com/u/4850686?v=4","description":"Featured Laravel Artisan, DevOps & New Relic Consultant | Building Scalable Systems with Precision \n","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":1370}},"image":"https://media.daily.dev/image/upload/s--1KxV4ohY--/f_auto/v1722860400/public/Placeholder%2007","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":3},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"sharedContent":{"@type":"WebPage","url":"https://api.daily.dev/r/gXVDPlvOx"},"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/laraveldev","name":"Laravel Dev"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Laravel Dev","item":"https://daily.dev/squads/laraveldev"},{"@type":"ListItem","position":3,"name":"How We Made Our Multi-Tenant Tests 25x Faster with Stancl Tenancy Package"}]}
```

