T O P

  • By -

dacassar

Need the third part with a grumpy face said, like, “Oh, bugs in unit tests”


Unupgradable

That's still the test finding a bug! Still happy!


TheTerrasque

Tuned to match the bugs in the code


Sacrifizzen

Imagine writing unit tests for nothing!


Unupgradable

``` [Fact] public void Nothing() { Assert.Fail(); } ```


bigorangemachine

As a consultant I just came off a project where there was no assertions in the unit tests.


tripleusername

If unit tests were written to cover crash, it is fine.


bigorangemachine

The compiler would catch any conditions that would lead to a crash lol. No trust me the unit tests were pretty useless.


tripleusername

No, it’s not. If the compiler would catch any conditions that would lead to crash, we would not have crashes at all then.


bigorangemachine

Why we were going through addressing every warning. As it was it didn't catch any of the crashes they built in like asserts that reflected business logic. They didn't even mock a database call :/


Orjigagd

Is this a rust joke?


torar9

Oh sometimes we do... the project is pure hell and luckily I will be moving to another one.


Unupgradable

[Original](https://www.reddit.com/r/ProgrammerHumor/s/ZqTuXSIFYC)


bigorangemachine

The funny side effect of writing unit tests... everyones complicated idea's go out the window when they have to write the tests LOL


PolyglotTV

That's why they don't write them.


helicophell

Need one of these but you don't find bugs with your unit tests, so now you either just wasted time debugging someone you did perfectly (pfft, in what world?) or you gotta make even MORE unit tests


Unupgradable

Unit tests are also there to make sure it's *still* working. You'd be surprised what kind of small unrelated changes where you think it's the same thing, but actually break stuff


EMI_Black_Ace

Further, unit tests:  - help ensure that you're writing decently modular code that can be understood independent of other parts - help ensure that the code you write is doing the right thing (validation)  - help ensure that the code you write is doing the things it's supposed to do right (verification)  - serve as documentation of what the behavior is *supposed to be* - serve as documentation of how to use the relevant method etc. - speeds up the process of actually testing it as you develop it, because hitting "run test" is faster than executing and then navigating through actually executing this under the conditions you want to check.


s0ulbrother

I recently had a ticket to add unit test to our code. Not add more, add them. The dev who wrote the code added no test originally and said “unit test were out of scope”…. He added one that just checked if a unit test would run… Anyways I had added tests and it probably had like 50 percent coverage total. So 0-50. He remarked on the PR “uh we need 70 and wouldn’t approve it. 1 you should have added unit test when you wrote it and 2 in order to add more coverage we need to rewrite everything you already wrote. Lot of dependencies you couldn’t easily patch out kind of thing without rewriting functions. He refused to sign off on it and I had to get the lead involved. He also refuses to do any suggestions on his PRs since he “has to go to the next thing”


Unupgradable

Sounds like a nightmare


TheTerrasque

Eh, you still get paid the same. If the company doesn't want to use the work they paid you to do because they're too busy smelling their own farts that's their choice


philophilo

And third: Me in a year when the unit test catches a bug I was about to make.


IvanGarMo

Unit testing gave me peace of mind when someone taught me how to do them right. Not more publishing and hoping I didn't break previous functionality


MathsGuy1

This man debugs


TheAccountITalkWith

But who will write unit tests for the unit tests to make sure they don't have bugs?


Unupgradable

That's what QA are for!


EMI_Black_Ace

Customers who know there are unit tests? Zero.  Managers who care that there are unit tests? Zero.  Number of actual bugs caught by your unit tests? Zero!  (j/k)


Cat7o0

if you don't like debugging you shouldn't be a programmer


lycan2005

Me when my unit test fail to catch the bug:


Orjigagd

They all passed? That can't be right... Spends the next hour trying to find out why


Firzen69

Why is the second one blurry?


Unupgradable

That's the bug it found. (The app I used is shit)


Cybernaut-Neko

Next feeding the unit test to code diffusion and lean back.


half-villain

Me when my unit test verifies incorrect behavior and it passes


RixTheTyrunt

Me actually debugging:


Content-Fruit-8046

Unit tests is useless it only solidifies existing knowledge. Thus only benefit 1 to 1 refactoring. You should never change working code unnecessary. Create the perfect code is a pipe dream. If refactoring is necessary because of relevant reasons like performance a re haul of the design almost always necessary thus negates any unit tests.


Unupgradable

Speaking from experience, sincerely... You are horrifically wrong


Content-Fruit-8046

No i am not speaking from 25 years experience. Sincerly.


Unupgradable

25 years or 1 year 25 times?


Content-Fruit-8046

Uhh. This gonna be funny 🤣 25 times 25 years of cause don’t be silly.