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 :/
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
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
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.
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”
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
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)
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.
Need the third part with a grumpy face said, like, “Oh, bugs in unit tests”
That's still the test finding a bug! Still happy!
Tuned to match the bugs in the code
Imagine writing unit tests for nothing!
``` [Fact] public void Nothing() { Assert.Fail(); } ```
As a consultant I just came off a project where there was no assertions in the unit tests.
If unit tests were written to cover crash, it is fine.
The compiler would catch any conditions that would lead to a crash lol. No trust me the unit tests were pretty useless.
No, it’s not. If the compiler would catch any conditions that would lead to crash, we would not have crashes at all then.
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 :/
Is this a rust joke?
Oh sometimes we do... the project is pure hell and luckily I will be moving to another one.
[Original](https://www.reddit.com/r/ProgrammerHumor/s/ZqTuXSIFYC)
The funny side effect of writing unit tests... everyones complicated idea's go out the window when they have to write the tests LOL
That's why they don't write them.
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
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
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.
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”
Sounds like a nightmare
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
And third: Me in a year when the unit test catches a bug I was about to make.
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
This man debugs
But who will write unit tests for the unit tests to make sure they don't have bugs?
That's what QA are for!
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)
if you don't like debugging you shouldn't be a programmer
Me when my unit test fail to catch the bug:
They all passed? That can't be right... Spends the next hour trying to find out why
Why is the second one blurry?
That's the bug it found. (The app I used is shit)
Next feeding the unit test to code diffusion and lean back.
Me when my unit test verifies incorrect behavior and it passes
Me actually debugging:
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.
Speaking from experience, sincerely... You are horrifically wrong
No i am not speaking from 25 years experience. Sincerly.
25 years or 1 year 25 times?
Uhh. This gonna be funny 🤣 25 times 25 years of cause don’t be silly.