4 ms·
> I’ve heard managers and teams mandating 100% code coverage for applications. That’s a really bad idea. The problem is that you get diminishing returns on our
by titzer 9y ago
> I’ve heard managers and teams mandating 100% code coverage for applications. That’s a really bad idea. The problem is that you get diminishing returns on our tests as the coverage increases much beyond 70%...
I call bullshit.
I work on V8, on JITs and WebAssembly. 70% coverage for these code bases would be absurdly low. We would never ship code that is that poorly tested, and you shouldn't either.
> You may also find yourself testing implementation details just so you can make sure you get that one line of code that’s hard to reproduce in a test environment. You really want to avoid testing implementation details because it doesn’t give you very much confidence that your application is working and it slows you down when refactoring. You should very rarely have to change tests when you refactor code.
What in the. serious. fuck. Of course tests test implementation details. Because _implementation details_ are where the goddamn bugs are.
> ... Maintaining tests like this actually really slow you and your team down.
That's the whole _point_. It slows you down in the short term but it keeps you from experiencing a full-on system meltdown when everything seems to be breaking at once.
Please don't follow the advice of this. It's total crap.
If you've never worked on a system that has survived more than 3 years, sure, go right ahead, run against the wall. But when you work on a system survives 5, 10 (V8), or 20 years (HotSpot JVM), then you really, really want to have good tests.
- away2017throw 9y agoNo offence, but you work in a bubble of sorts. In enterprise we are absolutely expected to run against a wall - preferably fast.
- titzer 9y agoThe bubble happens to be at the bottom of everything everyone runs. If we--or kernel folks for that matter--applied the advice of the article to our development practices, our system meltdown would be your system meltdown. Sure, you have requirements from management. So do architects and engineers for building bridges. Yet they still have a duty to build bridges that don't fall down.
- Chris2048 9y agoOK, so don't then. You are still in a bubble, important or otherwise. You can't expect me to throw out the service manual for my old Volvo because NASA wouldn't build a space probe to those standards.
- jcrben 9y agoAre you suggesting that the Linux kernel is unit tested? Last I checked, I couldn't find them. And discussions online say the same (e.g., https://news.ycombinator.com/item?id=9543336 https://news.ycombinator.com/item?id=9543336 and https://news.ycombinator.com/item?id=9544306 https://news.ycombinator.com/item?id=9544306). Kernel bugs tend to show up in userspace. Fortunately, integration-oriented projects have arisen more recently such as https://kernelci.org/ https://kernelci.org/ and https://github.com/os-autoinst/openQA/ https://github.com/os-autoinst/openQA/ Anyhow, it would make me a bit sad if the v8 team is writing unit tests tightly coupled to the implementation. I've messed around with the codebase and I didn't see tests like that - could you point to some?
- w4tson 9y agoRunning against the wall in the enterprise is what management expect but in my experience it’s down to developers “holding their nerve” to use the proper process (unit tests, PRs etc). It’s not even necessarily experience because I see the experienced devs do this all the time. But your good developer will know that when the feature is so important that it needs “rushing”, aka straight to prod or, skip QA etc then that’s exactly the time to stand firm and write those unit tests instead of throwing crap over the wall and making it next weeks defect.
- hacker_9 9y agoI find a lot of enterprises follow TDD.
- away2017throw 9y agoOh yeah, some are extremely vulnerable to predatory TDD evangelists. You won't find many functional programming ones though.
- smackfu 9y agoEnterprise software being known for its code quality.
- pwim 9y agoThe author of the post agrees with you that library code is different: > I should mention that almost all of my open source projects have 100% code coverage. This is because most of my open source projects are smaller libraries and tools that are reusable in many different situations (a breakage could lead to a serious problem in a lot of consuming projects) and they’re relatively easy to get 100% code coverage on anyway.
- titzer 9y agoThe thing is, everything that survives becomes a library, as someone will always find a way to try to reuse it.
- AlexCoventry 9y agoLet them write the comprehensive test suite, then. Your reasoning is a classic context for YAGNI.
- rootlocus 9y ago> I work on V8, on JITs and WebAssembly. 70% coverage for these code bases would be absurdly low. We would never ship code that is that poorly tested, and you shouldn't either. Tell that to a gamedev company.
- hacker_9 9y agoAs a counter, in this thread [1] a Rare employee says they follow TDD and it's revolutionised their development process. [1] https://news.ycombinator.com/item?id=14802333 https://news.ycombinator.com/item?id=14802333
- kartan 9y ago> What in the. serious. fuck. Of course tests test implementation details. Because _implementation details_ are where the goddamn bugs are. Testing is about testing inputs and outputs, not implementations details. Bad testing checks if you called this function or if you accessed this data. Good test checks that for a given input you get the expected output. > Please don't follow the advice of this. It's total crap. The general tone of your comment is non-constructive, lacks accuracy and appeals more to your status as "working in V8" than to real reasoning. It is a shame that it is so high in this thread. :( You may have some good points, but just by reading your comment I can't get them.
- p0nce 9y agoIf you have Google money and work on compilers, surely tests are more important than for say, a B2C app with lots of UI.
- MartinCron 9y agoSo many developers are so myopic that they can’t imagine a scenario different enough from their lived experience that people would want to do things differently. When people say “in the real world” they really mean, “in my insular world”
- fersab 9y agoI totally agree with you on this one! The tone is absolutely immature and frankly disgusting. I would never hire a person with this kind of attitude, frankly because it is the ultimate creativity-killer in a team. This type of attitude is creating a culture where everyone is "to scared to learn" by being to scared to comment on things, or even to ask a simple question. So sad to see this...
- titzer 9y agoSorry for the harsh tone--probably an overreaction--but I think creativity is not the primary variable to optimize for in software development. I recognize that this opinion is a product of where I've gotten stuck in the software stack. However the OP's advice was basically "don't write tests because they slow you down." They even said that 100% code coverage was "a really bad idea". The OP's attitude was flippant, dangerous, and IMO, stupid. Don't follow this advice.
- ryanmarsh 9y agoA CRUD app being written for the nth time does not require the same coverage as something as complex as the JVM.