Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
sariel84473yI actually kind of agree with him.
A hotfix is not the solution.
Think of it like this. Your app has hurt itself and is bleeding everywhere. In order to save your app you apply a compress to the wound until medevac.
The real solution to fix the issue is to disinfect and suture the wound. Then you can spend time on writing the test to ensure that it doesn't happen again. -
@sariel I would've agreed with it if he would've added them for his changes in the first place, but he didn't because he didn't know how to test them, and the manager approved because it was his first "big" feature. I mean, this was just adding pretty much the same functionalities we currently have with little differences. But NO, he didn't know how.
-
Knowing how quickfixes often end up living indefinately it doesn't hurt to put in a unit test. A unit test should be added just as quickly as it should be removed on refactoring.
-
Root797793y@devdiddydog This.
Code without specs is wrong. A hotfix, of all things, should not be wrong.
Removing the specs after fixing the bug properly doesn’t take long at all, and the specs themselves can help with writing both the proper solution and its specs.
And it’s true, sometimes hotfixes become the de facto fix, and stay around indefinitely. Permanent code should absolutely have specs.
If it’s about time and taking longer because you’re writing specs in addition to the fix… ask yourself how you know it works if you haven’t written tests for it. Maybe it only works on your machine? Furthermore, writing specs for the obvious cases almost always makes me think of new scenarios that I need to test — and that don’t always work without some additional code changes. You don’t want to release a hotfix that causes additional problems.
tl;dr
Always write specs, even for hotfixes.
Feel free to show him this reasoning if you think it will help! :) -
Well if the hotfix is a good fix, why not? If the test isn’t needed anymore, it can be deleted. I have a half eaten sandwich in my fridge I no longer need, but it’s not ruining my life. I can easily throw it away and move on...
-
It’s partially eaten bc the bread is terrible! I only ate the ham and cheese...bc ham is always good, regardless of shit
-
We started to require unit tests for all hotfixes to prevent regression.
Massively increased future code quality because the software was so complex people kept breaking seemingly unrelated components.
Even if the code to fix the issue is a temporary fix, the expected input and output of the test shouldn't change for the permanent solution so the time taken for the unit test is not a waste.
Related Rants
Today I got a reply to a PR comment from a coworker literally stating that "it's not a good practice to add unit tests to hotfixes".
I can't, just can't. Left me speechless. Wonder where this guy gets his "good practices" from.
rant
good practices
unit tests
hotfixes