Skip to content
DevMeme
1727 of 7435
The Art of Making Unit Tests Agreeable
Testing Post #1931, on Aug 17, 2020 in TG

The Art of Making Unit Tests Agreeable

Why is this Testing meme funny?

Level 1: Changing the Rules

Imagine you’re taking a math test at school and you get some answers wrong. The right thing to do would be to study and correct your mistakes so you get the answers right next time. But instead, you sneak in and change the answer key to mark your wrong answers as if they were right. Now your test looks perfect – you got a 100%! But did you actually learn math or fix your mistakes? Nope. You just changed the rules to make yourself look good.

This meme is joking about the same idea, but with computer code. The “build” is like the test at school, and the unit tests are the answer key checking the code’s work. When the code “fails the test,” it’s like getting a math problem wrong. The hard but honest way is to fix the code (learn and correct the mistake). The cheat is to rewrite the tests (change the answer key) so that it says your code was right all along. Drake in the meme is basically the developer saying, “I’d rather change the rules than fix the mess.” It’s funny because it’s obviously a cheeky, wrong thing to do – just like cheating on a test – and yet every programmer understands the temptation. The joke reminds us of that silly feeling when you just want the green check-mark (or a good grade) without doing the real work to earn it.

Level 2: Cheating on Tests

Let’s break this down in simpler terms. When developers write unit tests, they’re basically creating little check-ups for their code. Each unit test calls a function or part of the code with specific inputs and checks if the output is what it should be. Now, imagine you run all these tests (this often happens automatically in a build, like on a CI server such as Jenkins or GitHub Actions). If one of those tests fails, it means the code didn’t do what the test expected. Essentially, the code has a bug or at least doesn’t match the assumed requirements. At that moment, a responsible developer would fix the code so that it produces the correct output and the test passes. That’s the first line in the meme: “FIX YOUR CODE TO PASS UNIT TESTS” – in other words, make your code better so that it meets the test’s expectations. Drake is saying “nah” to this, which is ironic because that’s the normal, good approach!

Why would Drake (the developer in the joke) reject fixing the code? Because sometimes, fixing code is hard or time-consuming. Maybe the code is complex, or the deadline is looming, or the developer is a bit lazy (it happens 🤷). The meme jokes that instead of doing the hard work on the code, the developer chooses a sneaky shortcut: change the test to accept the code’s current behavior. That’s the second line: “FIX YOUR UNIT TESTS TO PASS YOUR CODE.” It means editing the test cases so that they expect whatever the code is currently doing, even if the code is wrong. Drake gives a thumbs up here, meaning “Yep, do that!” This is funny because it’s the opposite of best practices. It’s like saying, “If reality doesn’t match our expectations, let’s just change the expectations.” In a testing context, it’s considered cheating. You’re making the tests pass not by solving the underlying problem but by telling the tests to ignore it.

To visualize this, consider a simple example. Say we have a function square(x) that should return x². And we wrote a test for it: it expects that square(2) equals 4. But imagine our function is buggy and returns 5 instead. A proper fix is to go into the code and correct the logic. The shortcut fix is to go into the test and change the expected value to 5. For example:

# A buggy function (it adds 1 by mistake)
def square(x):
    return x * x + 1

# Original test: this should pass if square is correct
assert square(2) == 4   # This fails currently, because square(2) == 5

# "Fixing" the test instead of the code:
assert square(2) == 5   # Now the test passes, but we've just accepted the bug as normal!

In the code above, we modified the test instead of the function. The test suite is all green now (hooray, the build passes!), but obviously 5 was the wrong answer for 2². We basically taught the test to expect the wrong behavior. This defeats the purpose of unit tests, which is to catch mistakes. It’s like erasing a red F on your exam and writing an A yourself – sure, now it looks like you aced it, but you haven’t actually learned or fixed anything.

The Drake meme format makes this scenario easy to understand: it’s two panels of Drake from the “Hotline Bling” video. In the first panel (orange jacket, hand up) he’s rejecting something – here he’s rejecting “Fix your code to pass unit tests.” In the second panel (yellow background, pointing approvingly) he’s endorsing “Fix your unit tests to pass your code.” The humor comes from showing a developer preferring the wrong solution because it’s easier in the moment. This is a form of technical debt – a term we use when short-term easy fixes make more work later. If you keep adjusting or disabling tests just to get passing builds, you’re accumulating problems under the surface. Eventually, you might have to do a big cleanup (a refactoring) or you’ll face a surprise bug in production that the tests should have caught but didn’t (because you told the tests to ignore it!).

So in plain terms: the meme highlights a bad habit some coders have. Instead of fixing their buggy code, they change the tests (or even delete the tests) so everything “passes.” It’s funny to developers because it’s a well-known joke: “Works in my code, so the test must be wrong!” It’s a tongue-in-cheek reminder that while this trick might make the report green today, it’s not a real solution. Good engineers know you should trust well-written tests and fix the code – not the other way around. Drake choosing the opposite is just our community’s way of laughing at ourselves when we’re lazy or desperate.

Level 3: Deadline-Driven Development

At the highest level, this meme zeroes in on a unit testing anti-pattern that seasoned engineers know all too well. It’s poking fun at how under pressure (like tight deadlines or an overnight CI build failure), some developers will prioritize getting a green build at any cost. In proper TDD (Test-Driven Development), failing tests are supposed to drive you to improve the code. Here, Drake flips that script: instead of fixing the code logic to satisfy the tests (the right thing), he endorses tweaking the tests to accept the code’s current behavior (the quick-and-dirty thing). This reversal is darkly humorous to experienced devs because it caricatures a real temptation: when a build fails, do you refactor the code or just edit the tests so they pass?

The top panel text “FIX YOUR CODE TO PASS UNIT TESTS” is what any software craftsman would preach – if a unit test fails, it’s indicating a problem in your implementation. But Drake (with that iconic nope face) is rejecting it. Why? Because let’s face it, fixing code can be hard. It might uncover deeper design issues or require untangling some gnarly logic. It’s much easier to just change the test’s expected value or conditions. The bottom panel’s punchline “FIX YOUR UNIT TESTS TO PASS YOUR CODE” is Drake giving a thumbs-up to that lazy shortcut. It satirically captures the anti-TDD attitude: treating tests not as guiding lights for quality, but as annoying obstacles to be adjusted or silenced.

This is relatable developer humor because many of us have witnessed (or heaven forbid, done) this at least once. Failing tests are a common developer pain point – perhaps a QA test or continuous integration check is blocking your merge minutes before the deadline. Under panic, someone thinks, “The code kinda works, maybe the test is too strict or outdated. Let’s just change the test.” It’s the software equivalent of fudging the numbers to make the report look good. CodeQuality purists cringe at this because it undermines the whole point of testing. Instead of tests catching a bug or a regression, the bug gets blessed as “expected behavior.” You’ve essentially told your test suite: “No no, it’s not a bug, we meant to do that.” This is how technical debt accumulates – short-term passes that create long-term problems. Today’s quick fix becomes tomorrow’s 3 AM outage when the unchecked bug bites in production. As a cynical saying goes, “It passed all tests… because we lowered the bar.” 🥴

Digging a bit deeper, there’s an ironic truth: sometimes tests are wrong. Maybe requirements changed and tests weren’t updated, or the test itself was poorly written. Seasoned developers will investigate a failing test to see if the test logic is flawed or if the code truly has an issue. But the meme’s joke is about intentionally choosing the path of least resistance: assuming the code is infallible and therefore bending reality (tests) to fit the code. It’s a great commentary on developer productivity vs. integrity. Sure, you “saved time” by editing the test (your build is green and the manager is off your back), but you’ve sacrificed trust in the test suite. The next person who runs the tests won’t catch that bug, since the tests now conform to the bug. This false sense of productivity can haunt a project later. In proper workflow, tests are like an alarm system – you’re supposed to fix the fire in the kitchen, not just remove the battery from the smoke alarm because it’s making noise. 🚨

In summary, experienced devs laugh (and groan) at this meme because it nails a core truth: the easiest way out is rarely the right way out. The Drake format underscores the absurdity – no one openly says they prefer to rewrite tests over fixing code, yet in crunch time we see it happen. It’s a sly nod to the shortcuts we justify when chasing that all-green test suite. As a result, the meme resonates with anyone who values testing but has felt the pressure to “just make it pass.” It’s hilarious and painful, because we’ve seen how modifying tests instead of code is like sweeping dirt under the rug. Sure, the floor looks clean now (🎉 all tests passing), but the underlying mess is still there, waiting to trip someone up later.

Description

A classic 'Drake' meme format with two panels. In the top panel, the rapper Drake is shown with a look of disapproval, hand raised in a 'no' gesture. The adjacent text reads, 'FIX YOUR CODE TO PASS UNIT TESTS'. In the bottom panel, Drake has a pleased, knowing smile. The text next to him reads, 'FIX YOUR UNIT TESTS TO PASS YOUR CODE'. A watermark for 't.me/dev_meme' is in the bottom-left corner. This meme satirizes a common anti-pattern in software development. The correct and disciplined approach when a unit test fails is to debug and fix the application code. The humorous, lazy, and often-tempting shortcut is to simply modify the test itself to accept the code's incorrect behavior, creating a 'green' build without actually fixing the underlying issue. It's a cynical nod to the pressures of deadlines and the human tendency to choose the path of least resistance, even if it leads to technical debt

Comments

7
Anonymous ★ Top Pick Why argue with your code when you can just gaslight the unit test into believing it was wrong all along?
  1. Anonymous ★ Top Pick

    Why argue with your code when you can just gaslight the unit test into believing it was wrong all along?

  2. Anonymous

    Career milestone: replacing every assertEquals() with assertDoesNotThrow() and calling it “realigning tests with the business roadmap.”

  3. Anonymous

    The same developer who insists on 100% code coverage in PR reviews has a personal project with a single test that just asserts true === true

  4. Anonymous

    Ah yes, the classic 'make the tests pass' strategy - where 'pass' is interpreted very liberally. It's like debugging by commenting out the assert statements: technically the CI pipeline goes green, but you've just transformed your test suite from a safety net into a participation trophy. Senior engineers know this is how you end up with 100% code coverage and 0% confidence in your deployments - the tests become elaborate theater, performing their green checkmarks while the production bugs wait patiently in the wings for their Friday 5 PM debut

  5. Anonymous

    TDD zealots weep left, battle-scarred architects nod right - because refactoring tests is the tech debt no one audits

  6. Anonymous

    When tests assert implementation details, refactors become felonies - we update snapshots, loosen the mocks, and pray mutation testing isn't enabled

  7. Anonymous

    Modern TDD: red → re-baseline the snapshots → green - because nothing fails once you redefine “expected.”

Use J and K for navigation