r/badcode • u/koenigsbier • Dec 23 '21
c# I was wondering how could this test pass... Actually it doesn't, none of the tests work. We never run them, not even in our CI/CD pipelines. Nice !
616
Upvotes
121
u/MTB-and-beer Dec 23 '21
Truly amazing, code reviews are for suckers, amirite?
27
u/[deleted] Dec 23 '21
Can the ResponseCode be 0? Because in that case it looks like it would pass to me because nothing would ever get asserted.
9
u/Micthulahei Dec 23 '21 edited Dec 23 '21
Unless ResponseCode is a property that returns positive value once and then zeroes an underlying field. And that's what this test case is for.
EDIT: I guess in this case the test case is supposed to pass when ResponseCode is zero and fail when it is not. the if statement is redundant but other than that the test should work.
4
u/Deadly_chef Dec 23 '21 edited Dec 23 '21
When your employer requires tests but you don't know how to implement them properly
18
u/[deleted] Dec 23 '21
Image Transcription: Code
[Dark Theme.]
I'm a human volunteer content transcriber and you could be too! If you'd like more information on what we do and why we do it, click here!
5
u/[deleted] Dec 23 '21
Can't have pipeline failures if you don't run tests :tap_temple:
1
u/Xiaopai2 Dec 23 '21
Wow, how does that even happen? No one ever noticed that the pipeline always goes through without issues? No one ever ran test manually to check everything is in order before pushing? Or did people know and just ignored it anyway? But then why even write tests in the first place?
2
u/SeesawMundane5422 Dec 24 '21
Reminds me of the time I inherited a team of developers and an app. The app had unit tests, presumably put there by original developers.
Current developers did not run them. Did not know how to run them. I had to teach them how to run them and how to update them. To be fair, they took right to it. Totally got it once I explained the how’s and why’s. But blew my mind how continuity can just be completely severed by too many people leaving the team at once.
2
u/QBrute_ Dec 27 '21
Can't fail tests if you never run any.
1
u/eternityslyre Dec 24 '21
As I always like to say, the only thing more frustrating than when I can't get things to work, is when I can't get things to not work. If nothing I do has any effect on the code execution, I'm clearly not making the right changes.
1
u/chillen678 Dec 27 '21
Danny boy the pipes the pipes are calling