News for hackers. Stuff that matters.
Re:We need to talk about testing by yourenotsmart on Wednesday July 28, 2021 @06:05AM (#27982090)
Unit testing has become a bit like a diploma. Something society requires to acknowledge your quality, but that is mostly pro-forma and very poorly correlated with domain skills or intelligence.

Those are systems that have firmly crossed from "simulation" territory to "simulacra" territory.

People who think about the actual value of specific tests like you are few and far between. Most feel constrained by peer pressure and the need to do what they perceive is correct by definition.

Re:We need to talk about testing by erhk on Wednesday July 28, 2021 @08:03AM (#27982806)
Tests are to stop the future programmer from breaking your code.
Re:We need to talk about testing by cgrealy on Wednesday July 28, 2021 @08:55AM (#27983144)
Tests (specifically unit tests) are a way of documenting your assumptions about how a pice of code will be used.
Re:We need to talk about testing by postalrat on Wednesday July 28, 2021 @08:37AM (#27983012)
By making tests so brittle you can't change any code without updating tests. And who wants to do that?
Re:We need to talk about testing by carlmr on Wednesday July 28, 2021 @10:48AM (#27984451)
If the behavior changes, the requirements have changed or you previously had a bug. That's not brittle tests.
Re:We need to talk about testing by postalrat on Wednesday July 28, 2021 @01:48PM (#27986860)
Someone wants to test:

  function do_add(a, b, add) {
    return add(b, a);
  }
And does something like:

  do_add(1, 2, add)
  expect(add) to be called with (2, 1)
Then the function is changed to:

  function do_add(a, b, add) {
    return add(a, b);
  }
Oops, broke the test. Is this a type of behavior change that you expect would break the test? Often there are many ways to correctly do something and a good test should allow any of them.
Re:We need to talk about testing by carlmr on Thursday July 29, 2021 @02:08AM (#27993366)
But that's not a behavioral change, only bad testing. The test wouldn't be brittle if the behavior of adding was locked down completely.
Re:We need to talk about testing by yourenotsmart on Thursday July 29, 2021 @12:06PM (#27998071)
Any test that uses mocks is therefore "bad testing".
Re:We need to talk about testing by yourenotsmart on Wednesday July 28, 2021 @02:57PM (#27988101)
The very problem is that tests failing is not necessarily due to behavior changing but implementation details not affecting behavior changing.

This is especially the case when tests rely on mocks, which don't really implement the BEHAVIOR of a dependency, but rather represent a "replay" of a specific call stack sequence.

Re:We need to talk about testing by temporama1 on Wednesday July 28, 2021 @08:16AM (#27982887)
QED
Re:We need to talk about testing by rogual on Wednesday July 28, 2021 @08:49AM (#27983100)
Rings true. I often write more unit tests in a team than I otherwise would, even if I don't think they add that much value, just because no pull request ever failed review for having too many unit tests, and any time spent arguing about it is time I'd rather spend building the next feature.