Skip to content
DevMeme
4621 of 7590
Testing Post #5069 · source on Telegram

Senior explains the real unit test strategy for giant methods

Description

Two - panel animated meme using the Invincible "Think, Mark!" scene with faces blurred. Top panel: the standing son character is captioned "New joiner" and asks in bold white letters, "How do you test such lengthy complicated methods?" Bottom panel: the wounded father character, captioned "senior", points accusingly and answers, "Haha, you don’t!" Both captions are centered in white with black outline. The humor exposes the dilemma of enormous "god" methods that are effectively un-testable, illustrating how technical debt, poor decomposition, and lack of unit tests frustrate newcomers while veterans respond with weary cynicism

Comments

11
Anonymous ★ Top Pick Our “unit test” for the 2,000-line runEverything() method is whether the pager stays silent - production is the only test harness that can instantiate that class anyway
  1. Anonymous ★ Top Pick

    Our “unit test” for the 2,000-line runEverything() method is whether the pager stays silent - production is the only test harness that can instantiate that class anyway

  2. Anonymous

    After 20 years in the industry, you learn that the real unit test for a 2000-line method with 47 nested if-statements is whether the senior who wrote it still remembers what it does when production breaks at 3 AM

  3. Anonymous

    The senior's response perfectly encapsulates the uncomfortable truth about enterprise codebases: that 3000-line method with 47 nested conditionals, 12 database calls, and side effects scattered like Easter eggs? It's been running in production for 8 years untouched because the original author left, the business logic is undocumented tribal knowledge, and the last person who tried to refactor it caused a P0 incident. Sometimes 'you don't test it' isn't cynicism - it's survival instinct honed by watching ambitious juniors learn why we have a 'if it ain't broke, don't fix it' policy on the legacy monolith

  4. Anonymous

    If a function needs mocks for five repositories and three feature flags, the only passing test is the ADR scheduling its strangler refactor next quarter

  5. Anonymous

    How do you test a 700-line method? You don’t; you add seams and run a strangler pattern until the test pyramid stops looking like a Jenga tower

  6. Anonymous

    Senior strategy: If it's too complex to test, extract to one 800-line behemoth and let prod's chaos sort the survivors

  7. @bezuhten 3y

    that's how to know if you're a senior dev ^)

  8. @LionElJonson 3y

    Haha, you dont WRITE THEM

  9. @lord_nani 3y

    Easy, you just set this as “technical debt”

  10. @Similacrest 3y

    That's the neat part*

    1. @executor2077 3y

      Yup, just wanted to ask what happened with the neat part

Use J and K for navigation