News for hackers. Stuff that matters.
Re:Why Most Unit Testing Is Waste [pdf] by alfiedotwtf on Tuesday October 31, 2017 @07:17AM (#15592353)
This.

We tend to put a high value on code review, yet some don't value unit testing. Lean in and I'll tell you a secret:

... unit testing is automated, repeatable, code review!

Re:Why Most Unit Testing Is Waste [pdf] by blub on Tuesday October 31, 2017 @09:02AM (#15592879)
I don't see such a large overlap between code review and unit testing. Here's an example from one of my code reviews, where I discovered two issues:

1) A relaxed requirement was agreed to by the PO, but the remote developer wasn't aware of that and wrote code to fulfil the original complex requirement. The implementation was harder to understand and touched more areas of the code, leading to issue number 2.

2) By analysing the interactions between multiple units, I was able to determine that the code as implemented was in fact reading a setting too early, when it was not available, thereby having no effect at all compared to the already existing code. Ironically, this exact concern had prompted the negotiation with the PO which resulted in the relaxed requirement.

Interestingly the error was not caught by unit tests, because it didn't happen in a single unit. It wasn't caught by integration tests, because that particular online component was mocked and it passed code review by two other developers.

Re:Why Most Unit Testing Is Waste [pdf] by eric_h on Tuesday October 31, 2017 @04:01PM (#15596071)
Static analysis is another tool in the toolbox, and invaluable as well.
Re:Why Most Unit Testing Is Waste [pdf] by jryan49 on Tuesday October 31, 2017 @09:33AM (#15593083)
Your unit tests check the architecture of the code and the implementation is maintainable? I say that cause that's what I use code reviews for :P
Re:Why Most Unit Testing Is Waste [pdf] by fvdessen on Tuesday October 31, 2017 @07:34AM (#15592436)
Only if the tests and business code are not written by the same engineer.
Re:Why Most Unit Testing Is Waste [pdf] by dorfsmay on Tuesday October 31, 2017 @08:12AM (#15592616)
Which they typically no longer are when fixing a bug or refactoring.
Re:Why Most Unit Testing Is Waste [pdf] by mannykannot on Tuesday October 31, 2017 @08:26AM (#15592676)
How many times do you need to repeat the review of a given unit of code? (actually, that would have more chance of catching additional bugs than would rerunning the same unit tests.) Once you change the code, the existing unit tests are, by definition, invalidated (i.e. there is no value to being able to rerun them), while most higher-level testing will retain their validity. You have actually created an argument for automated higher-level testing (the author mentions that his position is often mistaken for an attack on test automation.)
Re:Why Most Unit Testing Is Waste [pdf] by nradov on Tuesday October 31, 2017 @09:12AM (#15592940)
No, changing the code doesn't invalidate the unit tests unless the API design contact changes.
Re:Why Most Unit Testing Is Waste [pdf] by mannykannot on Tuesday October 31, 2017 @09:21AM (#15592998)
By definition, unit tests test the implementation. A test at the API design contract level is an integration test. The only place where these are the same thing are pure (side-effect-free) functions that do not call other functions.
Re:Why Most Unit Testing Is Waste [pdf] by kafkaesq on Tuesday October 31, 2017 @01:06PM (#15594755)
... unit testing is automated, repeatable, code review!

Except when it isn't.

"Unit tests can be one form of code review (that also happens to have the advantage of being automated and repeatable). But should never be mistaken as substitute for actually understanding what the code does, why it does it and how it got that way. Which requires an incompressible amount of effort, analysis, and plain and pure grit", would be another take on the matter.