My Experience with Testing Disasters: The Importance of Proper Database Seeding
Amirul Islam
Backend Software Engineer (4+ yrs) | Data Engineer | Python, Cloud, Microsevices, System Design
The Mistakes We Make in Testing! Lessons from My Experience ??
At my first company, we needed a quick way to test OTPs (One-Time Passwords), so guess what? They used my personal phone number as the default recipient. Convenient, right? Well, fast forward to today—I've left that company long ago, but my phone keeps receiving OTPs from different banks, like I'm a secret millionaire opening accounts everywhere. ??♂? Annoyed, I blacklisted several numbers. Did that help? Not much.
The Next Company's Story ????
At my next job, the situation was even wilder. Somebody mistakenly used production data in a testing script. In just a few minutes, we had sent test SMS to 3.5 million users! Yes, you read that right—millions! And as if one mistake wasn't enough, it happened twice, in a single day. ??
Now, imagine if those SMS messages had been promotional offers, cashback promises, or discounts that could cause financial damage to the company. It would have been a full-blown disaster!
Moral of the story? Please don’t make mistakes like this. You never know how a tiny mistake could cause massive trouble for not just you, but the entire company in a matter of seconds.
Database Seeding: Why It Matters ??
So, what’s the takeaway? Proper Database Seeding is crucial. For those who aren’t familiar, Database Seeding means filling your database with initial or test data. It could be:
Why Do We Need to Seed the Database?
What Type of Data Should You Use for Seeding? ??
Simple answer: Garbage! Use absolutely nonsense for the development database—but make sure it's in the correct format, type, and size. For this, you can use libraries like:
For example:
The idea is to make it look real enough so that you can realistically test features, without actually affecting anyone.
Benefits of Seeding ??
Pro Tip: Never forget to rollback test data after testing. Always clean up so it doesn't affect your future tests.
Book Recommendation ??
I tried to give you a light overview of database seeding here. For more in-depth knowledge, I highly recommend a book that every backend developer should read: "Build APIs You Won't Hate" by Philip Sturgeon.
Thanks for reading, and remember: it's always better to use "fake garbage" than to create a real mess! ?????