logo
podcast Podcast
get help Get Unstuck

Picking a good test value

And avoid flaky tests

Joel Clermont
Joel Clermont
2024-02-23

This is a lesson I learned the hard way: Be careful when picking test values to make sure they can't collide with random faker data.

For example, if you're testing a wild card search against a few fields, don't use "ok" as your test value. Why not? Well, Faker can generate a random name that could potentially match, like "Brooks".

When this happens, your test will randomly fail, but then pass if you run it again. It might only happen one out of 500 test runs. Flaky tests are so frustrating!

Choosing a slightly more complex value like "search-term" can save you grief later.

Here to help,

Joel

P.S. Did you know we have a "pay what you want" book of security tips for your Laravel app?

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼
email
No spam. Only real-world advice you can use.