Episode 324 · December 23, 2019
Test suites often become brittle over time where small changes end up breaking various tests. One way to avoid that is by avoiding using hardcoded values in your test suite.
Sometimes it feels like you make a small change and it breaks a bunch of tests. These are called "brittle tests". Any little thing might cause them to fail. That's the last thing you want in a test suite. You want them to be reliable, and robust against changes.
One of the reason tests become brittle is because you're hardcoding values. Whether that's names, email addresses, or other content you're asserting, the result is the same: constantly broken tests.
Small changes should not affect your test suite, especially small tweaks to content or fixture data. What ends up happening is that our tests may assert that our code works but they ALSO assert that our fixture data is a very specific value.
Instead, we can make our test asserts validate dynamic values. This makes sure they only test our code, not the content or our fixture data. It makes things more reliable and way easier to maintain.
No transcripts available. Earn a free month
Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.