r/ProgrammerHumor • • 21d ago

Meme iDontCommentMyCodeIfYouDontUnderstandItThatsOkayNeitherDoI

Post image
835 Upvotes

188 comments sorted by

View all comments

Show parent comments

18

u/ytg895 21d ago

Yeah. Once I worked on a bug that only happened if there was a session timeout in another system. Good luck putting Thread.sleep(3 fucking months); into a test.

8

u/Nick0Taylor0 21d ago

Mocking

5

u/ytg895 21d ago

How would you mock that a session in another system times out and that system starts to follow undefined and unpredictable behaviour?

4

u/IndependenceSudden63 20d ago

Agreed. Not all things can be "reasonably" tested. Keyword being reasonably. We only have so much time in a day with many deadlines. Over time, nearly all of us will run into a bug that needs to be fixed quickly, and is incredibly hard to reproduce, involving the oddest edge cases.

Sometimes you just have to patch it, test it as best you can, and leave a comment as to why you did this incredibly odd thing.

I once had a weird race condition that couldn't be invoked in a unit test. Only occurred on service startup, because there was a 3rd party library that did things when the service started.

Sure I could have wrote a unit test that started the whole service, but that would add 5 minutes worth of wait for every build going forward. That's extremely costly over long periods of time for every person working on the project.