It'll be fun to refactor a codebase without unit tests
Why Most Unit Testing Is Waste [pdf]
31–40 of 159 posts
Re: Why Most Unit Testing Is Waste [pdf]
#32Earlier quoted context omitted.
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!
Only if the tests and business code are not written by the same engineer.
Re: Why Most Unit Testing Is Waste [pdf]
#33I disagree: https://henrikwarne.com/2014/09/04/a-response-to-why-most-un...
"In my experience, unit tests are most valuable when you use them for algorithmic logic. They are not particularly useful for code that is more coordinating in its nature." I agree in principle, but IME: * This kind of algorithmic code often makes up a fairly small proportion (~5%) of code written for most business driven applications - it's usually mostly coordination. Some domains may be different (and for them, un…
True, but you can have both types of tests, which lets you test algorithms (unit tests) and higher level combinations (integration tests) both in the best way. The right tool for the right job.
> Where you have algorithmic and integration code smushed together (this type of technical debt is, sadly, the norm 'in the wild'), again, integration tests work acceptably well whereas unit tests require a mess of mocks.
In many cases, you'd be better off separating the logic, which would let you have both types of tests, each for a different part of the logic.
> Integration tests do not have to be high level or slow.
No, but they are a different tool.
Re: Why Most Unit Testing Is Waste [pdf]
#34This has already been discussed to death, on 3 occasions: https://news.ycombinator.com/item?id=7353767 (268 comments) https://news.ycombinator.com/item?id=11799272 (280 comments) https://news.ycombinator.com/item?id=13815779 ("only" 24 comments)
Also, there's a followup by Coplien which has not been discussed: https://rbcs-us.com/documents/Segue.pdf So maybe this document should be the focus of the discussion now.
However, the title "Seque" is completely unspecific and hence totally useless. Given that title, I don't see how to submit this to HN in a way that it attracts readers.
This is really a pity.
Re: Why Most Unit Testing Is Waste [pdf]
#35Earlier quoted context omitted.
Legacy code = code without tests. You might write HQ code today, but without tests it'll become technical debt within a month or even a week down the line. Programmers come and go, unit tests are omnipresent.
All code is legacy code as soon as you type the semi-colon. It is wishful thinking that a suite of unit tests will prevent a refactor or small change from producing technical debt.
Re: Why Most Unit Testing Is Waste [pdf]
#36I disagree: https://henrikwarne.com/2014/09/04/a-response-to-why-most-un...
"In my experience, unit tests are most valuable when you use them for algorithmic logic. They are not particularly useful for code that is more coordinating in its nature." I agree in principle, but IME: * This kind of algorithmic code often makes up a fairly small proportion (~5%) of code written for most business driven applications - it's usually mostly coordination. Some domains may be different (and for them, un…
Re: Why Most Unit Testing Is Waste [pdf]
#37Earlier quoted context omitted.
The article addresses your first point in a big section: 1.4 The Belief that Tests are Smarter than Code Telegraphs Latent Fear or a Bad Process Your other point about only good programmers not needing unit tests is moot as you haven't followed it through to the conclusion. Namely, if bad programmers write bad code that needs unit tests, they're also going to write bad unit tests that don't test the code correctly. S…
My point was that even bad unit tests are better than both good/bad word docs or no unit tests. So even bad tests written by bad programmers have a value. They have a large COST too (which is what he's arguing), my argument was merely that the value might not be less than the cost, which is his assertion. > Software engineering research has shown that the most costeffective > places to remove bugs are during the tran…
Re: Why Most Unit Testing Is Waste [pdf]
#38Re: Why Most Unit Testing Is Waste [pdf]
#39Earlier quoted context omitted.
"In my experience, unit tests are most valuable when you use them for algorithmic logic. They are not particularly useful for code that is more coordinating in its nature." I agree in principle, but IME: * This kind of algorithmic code often makes up a fairly small proportion (~5%) of code written for most business driven applications - it's usually mostly coordination. Some domains may be different (and for them, un…
> Integration tests can test algorithmic acceptably well, but unit tests do not test integration code in an acceptable fashion. True, but you can have both types of tests, which lets you test algorithms (unit tests) and higher level combinations (integration tests) both in the best way. The right tool for the right job. > Where you have algorithmic and integration code smushed together (this type of technical debt is…
You can, but if your code is 95% coordination and 5% algorithmic, at most you'd want 5% unit tests.
>In many cases, you'd be better off separating the logic
Which is refactoring and if you're refactoring you need to have your code surrounded with tests to do it safely.
And, once you've done that, if you've already written integration tests for that logic and they perform acceptably well, there may be no point in rewriting the integration test as a unit test.
Re: Why Most Unit Testing Is Waste [pdf]
#40The normal practice for large scale codebases in complex domains is "the code is the spec". That is, the only specification for how the system should work is how it worked yesterday. In that case, unit tests serve as a great specification. Even tests that just duplicate the business code under test and assert that it's the same (A huge waste in normal cases) is useful. Because a Unit test is much better than a word d…
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!