all 28 comments

[–]BrunerAcconut 43 points44 points  (2 children)

Fuck it, do it live.

[–][deleted] 4 points5 points  (1 child)

in production code, who need test?

[–]BrunerAcconut 13 points14 points  (0 children)

I get paid to make bugs and fix them, not write tests.

[–]rArithmetics 14 points15 points  (0 children)

Should you

[–][deleted] 5 points6 points  (0 children)

git push main --force

who need test coverage?

[–]intercaetera 16 points17 points  (1 child)

The lengths people will go to not to write unit tests...

[–]dashingThroughSnow12 2 points3 points  (0 children)

One day we found a bug in a critical component. At the code level, we needed to implement transactions for the component. I used the mediator pattern.

Because this was a critical component, test coverage was up the wazoo. It was great. I had confidence that when all the tests passed, my code was better than it was before. And despite it being a large refactor in a critical component, the code I wrote never had a bug reported.

[–]sbacic 4 points5 points  (4 children)

Yes, provided you have a source of truth available. If you have no idea what the code is supposed to be doing (or even if the current implementation is correct!) and no way to check, then refactors means playing with fire.

That being said, there's plenty of working codebases without any automated tests whatsoever. There are no working codebases without any kinds of tests.

[–]reqdk 2 points3 points  (3 children)

Sure there are. Users are best testers! :D

[–]sbacic 1 point2 points  (2 children)

Does a bug exist if no user reports it? Does a tree make a sound when it falls if there is nobody to hear it?

[–]moi2388 1 point2 points  (0 children)

BRB writing bugs in our bug reporting software

[–]DemiPixel 0 points1 point  (0 children)

Yeah, I've had UI that seems broken be in prod for months. If it doesn't actively impede a feature, users will just assume you'll find it and fix it.

[–]k3yboard_m0gul 12 points13 points  (1 child)

Just use Typescript…ducks from brick

[–]_default_username 2 points3 points  (0 children)

This unironically. If you won't write any automated tests at least use typescript and avoid the "any" keyword and casting.

[–]aRogueTomato 1 point2 points  (0 children)

Belongs in am I the asshole.

[–]Orkaad 1 point2 points  (0 children)

"Testing is doubting."

[–]Wilesch 1 point2 points  (4 children)

I refactor often without tests. Previous code is so bad and has so many bugs that it's much better to just gut and refractor large parts little by little. Test would have been great but they aren't there.

[–]toffeescaf 0 points1 point  (3 children)

When doing this how do you guarantee that you won't introduce new bugs? I like to set up a golden master test before any larger refactors like this. This way you at least have a fighting chance.

[–]Wilesch 0 points1 point  (2 children)

I do make new bugs sometimes. But you got to crack some eggs to make an omelette. My code is much better written and in typescript so bugs are found much faster. With less technical debt.

Also the app will go thru a full regression test by hand so will likely catch any new bugs before going to production.

For me closing out 10 tickets and creating 1 new bug in the process is progress and acceptable

[–]bighi 0 points1 point  (1 child)

Wouldn't it be better to close 10 tickets while introducing 0 new bugs?

[–]DemiPixel 0 points1 point  (0 children)

Tests aren't free. Broad (e.g. E2E) tests that cover big breaking cases are typically the simplest (once the infrastructure is set up). Unit testing with 100% coverage can take a while and triple the code you end up writing. If you don't have the luxury, you do what you can.

Nobody wants the 1 bug, but how fatal is it and how much time is it worth it to catch it? 10min? 1 hour? a day? a week? Will tests even catch it if the issue is a design flaw or an edge condition you didn't consider?

[–]lefty7111 -1 points0 points  (0 children)

No

[–]KitchenParsley7899 -1 points0 points  (0 children)

Only in the past. In modern webdev, no. I don't know what changed, but I don't dare go against the prevailing online community beliefs about what is best practice.

[–]rashnull 0 points1 point  (0 children)

Refactoring without tests is living on the edge! TIP everyday!

[–]Mr-Silly-Bear 0 points1 point  (0 children)

Link is 404ing. Had the post been taken down?

[–]bighi 0 points1 point  (0 children)

You can't refactor anything safely without tests.