Earlier quoted context omitted.
Unpopular opinion, but I always say that unit tests are contracts for the API. If you don't want / don't need to make contract, don't do unit tests. Unit tests main purpose is not to improve code or reduce bug, it's main purpose is to verify the code to work against the contract that's defined in unit tests. Code improvement or bug reduction are added benefit, if any.
> Unpopular opinion, but I always say that unit tests are contracts for the API You’re talking about integration tests or e2e tests. Those don’t sound like unit tests.
Programmers should never trust anyone, not even themselves
71–80 of 163 posts
Re: Programmers should never trust anyone, not even themselves
#72That's the point of code reviews.
Trust me; I'm an expert on never trusting myself.
Re: Programmers should never trust anyone, not even themselves
#73> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. As somebody who primarily lives on the testing side of the house, I've definitely run into cases where the developer promises that their unit tests will make a new feature less buggy, then about 5 minutes later I either find a mistake in the test or I find a bug in something that the developer didn't think to test at all. I…
Re: Programmers should never trust anyone, not even themselves
#74You sort of have to trust yourself, but verify it against what others expect. That's the point of code reviews. Trust me; I'm an expert on never trusting myself.
Re: Programmers should never trust anyone, not even themselves
#75> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. If only :) Far too often I find myself working with tests that patch one too many implementation details, putting me in a refactoring pickle
Re: Programmers should never trust anyone, not even themselves
#76Earlier quoted context omitted.
Unpopular opinion, but I always say that unit tests are contracts for the API. If you don't want / don't need to make contract, don't do unit tests. Unit tests main purpose is not to improve code or reduce bug, it's main purpose is to verify the code to work against the contract that's defined in unit tests. Code improvement or bug reduction are added benefit, if any.
> Unpopular opinion, but I always say that unit tests are contracts for the API You’re talking about integration tests or e2e tests. Those don’t sound like unit tests.
Or to put it a different way, your unit tests should cover units that have a good boundary to the rest of the system. This should sound like a module, but there is reason to have module as a larger thing than your unit (most of the time there shouldn't be, but once in a while this is useful), and so while there is overlap it is often useful to consider them different.
Integration tests cover the API, but they do not test the API (well they often use some API as well, but the won't cover all your internal APIs.)
Re: Programmers should never trust anyone, not even themselves
#77> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. As somebody who primarily lives on the testing side of the house, I've definitely run into cases where the developer promises that their unit tests will make a new feature less buggy, then about 5 minutes later I either find a mistake in the test or I find a bug in something that the developer didn't think to test at all. I…
I reviewed hundreds of them, tried rewriting dozens of them. Eventually, realize that essentially all of the tests were just testing that mock data being manually manipulated by the test gave the result of test expected.
Absolutely nothing useful was actually being tested.
Some team spent a couple of years writing an unholy number of tests as a complete waste of time. Basically just checking off a box that code had tests.
Re: Programmers should never trust anyone, not even themselves
#78> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. As somebody who primarily lives on the testing side of the house, I've definitely run into cases where the developer promises that their unit tests will make a new feature less buggy, then about 5 minutes later I either find a mistake in the test or I find a bug in something that the developer didn't think to test at all. I…
> something that the developer didn't think to test at all. Raising hand, guilty as charged. I test for things based in my concept of how the system works, but those darn users may have other ideas! Actually, when I found a user who seemed to have a knack for finding bugs, they were gold and I let them know I appreciated their efforts. > unit tests should be used to baseline something after it ships That has not been…
Getting those ideas in front of you is the job of the product team.
It isn't your fault if the guy writing the ticket refuses to talk to the users/and or/you.
"Ticket meets acceptance criteria, please submit a new request for this new feature."
Re: Programmers should never trust anyone, not even themselves
#79> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. As somebody who primarily lives on the testing side of the house, I've definitely run into cases where the developer promises that their unit tests will make a new feature less buggy, then about 5 minutes later I either find a mistake in the test or I find a bug in something that the developer didn't think to test at all. I…
Re: Programmers should never trust anyone, not even themselves
#80> Failing tests indicate the presence of bugs, but passing tests do not promise their absence. As somebody who primarily lives on the testing side of the house, I've definitely run into cases where the developer promises that their unit tests will make a new feature less buggy, then about 5 minutes later I either find a mistake in the test or I find a bug in something that the developer didn't think to test at all. I…
In theory, but I've never seen anyone successfully write tests after something ships. By that time much of the context that should be documented in tests is forgotten.