this post was submitted on 20 Jul 2025
387 points (94.7% liked)

Programmer Humor

25253 readers
885 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] Kayana@ttrpg.network 5 points 6 days ago* (last edited 6 days ago) (1 children)

There are two different things mentioned here, which I feel I need to clarify:

First, what you said about merging / creating a PR with broken tests. Absolutely you shouldn't do that, because you should only merge once the feature is finished. If a test doesn't work, then either it's testing for the wrong aspect and should be rewritten, or the functionality doesn't work 100% yet, so the feature isn't ready to get merged. Even if you're waiting for some other feature to get ready, because you need to integrate it or something, you're still waiting, so the feature isn't ready.

At the same time, the OP's point about tests being supposed to fail at first isn't too far off the mark either, because that's precisely how TDD works. If you're applying that philosophy (which I personally condone), then that's exactly what you do: Write the test first, checking for expected behaviour (which is taken from the specification), which will obviously fail, and only then write the code implementing that behaviour.

But, even then, that failing test should be contained to e.g. the feature branch you're working on, never going in a PR while it's still failing.

Once that feature has been merged, then yes, the test should never fail again, because that indicates a new change having sabotaged some area of that feature. Even if the new feature is considered "essential" or "high priority" while the old feature is not, ignoring the failure is one of the easiest ways to build up technical debt, so you should damn well fix that now.

[โ€“] balsoft@lemmy.ml 1 points 6 days ago* (last edited 6 days ago)

I concede that on a feature branch, before a PR is made, it's ok to have some failing tests, as long as the only tests failing are related to that feature. You should squash those commits after the feature is complete so that no commit has a failing test once it's on master.

(I'm also a fan of TDD, although for me it means Type-Driven Development, but I digress...)