Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 5
    I'm going to disagree at least partially. Saying "see how long it takes to notice" is just against the point of having tests. The tests are supposed to tell me if it's broken. Structural code is obviously as important as any other code because if I were to break it my whole app would be broken. Commented Jun 30, 2021 at 22:08
  • 15
    @DerekC I didn’t say “see how long it takes them to notice.” I said “see how long it takes them to find the problem”. Some people obsess on having the finest grained tests without sanity checking or realizing they’re up against the law of diminishing returns. Commented Jun 30, 2021 at 22:14
  • 21
    I wish more people talked about diminishing returns in the World of Testing. Commented Jul 1, 2021 at 16:15
  • 4
    Exactly what I came here to say. When the unit test for your code looks almost exactly the same as the code itself, you have achieved the near-perfection of "obviously correct code". Just like "self-documenting code" doesn't need comments, "obviously correct code" doesn't need unit tests. When you write code like this, congratulate yourself, and skip the test. Commented Jul 1, 2021 at 17:42
  • 2
    @JounceCracklePop My experience here differs. My experience is that code with tautological tests is often code which mixes concerns so haphazardly that that was the only way the developer could think to test it. Refactoring it to separate concerns better would have been a good move (and when adequately refactored, it would hopefully look like the ideal code you mention), but if not, this is where the advice to "throw an integration test at it" makes sense, since the behaviour of such code is often an emergent property of the way it's wired together. Commented Jul 2, 2021 at 11:05