this post was submitted on 29 Jun 2025
25 points (85.7% liked)
Programming
21254 readers
24 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
We use something similar where I work. Not having a clear seperation between the parts of the name feels a bit noisy and hard to parse, so we use:
test_<function>__<context>[__<result>]
(pytest, Python, looks for functions starting withtest_
).So something like
test_clean_accounts__client_name_missing__fill_from_organisation_name
ortest_open_chest__unlocked_and_has_items__items_collected
.The double underscores make the linter unhappy, so that check is disabled for test names. It's helped guide how people with how they write their tests, shifting towards more BDD type testing, as the article points out as well it's also kept tests smaller and focused, and made our codebases more self documented. No one enjoyed adding docstrings and this seems to have encouraged slightly for TDD style work (we don't necessarily push TDD but there are use cases where it just makes sense, yet developers were avoiding it). It was a small changed that upped the general quality of tests and code, leaning into developer laziness rather than trying to fight against it.
It's also been useful for working with more junior engineers. On established projects they can just read through the tests. On newer projects we might pair code a wireframe of the program, get some test names written down, wrap them with
@pytest.mark.todo
markers, and let them have at it. The todo markers mean they can go more at their own pace without it feeling overwhelming with fails. We also sometimes do this when a bug, enhancement, or feature request comes in, we just create the test with the name then add atodo
(feature
,bug
, ...) so it doesn't break the flow, but is documented, and someone can pick it up later (people weren't always recording these in tickets.. So it's an improvement).