News for hackers. Stuff that matters.
Re:Write tests. Not too many. Mostly integration by olavk on Friday October 27, 2017 @03:00AM (#15566270)
> Good lord. Why integration tests?

Because they can find bugs and errors which unit tests cannot.

Re:Write tests. Not too many. Mostly integration by andybak on Friday October 27, 2017 @04:39AM (#15566671)
Funnily enough for the reasons carefully explained in the article. i.e. cost vs benefit, fragility etc.

Nobody disputes that if they came for free then full unit test coverage would be a good thing. The area open to reasonable debate is whether they give the best bang per buck in terms of testing (as opposed to the role of tests in TDD - which is a different kettle of fish: http://www.drdobbs.com/tdd-is-about-design-not-testing/22921... )

Re:Write tests. Not too many. Mostly integration by fnord123 on Friday October 27, 2017 @03:14AM (#15566315)
This is true. Areas where I have full unit test coverage tend not to have any bugs. What a waste of time to have written all these tests!
Re:Write tests. Not too many. Mostly integration by Matumio on Friday October 27, 2017 @03:20AM (#15566337)
Yeah, assuming you think it's not a bug when the backend API that you're mocking is accidentally removed or changes its response slightly.
Re:Write tests. Not too many. Mostly integration by fnord123 on Friday October 27, 2017 @03:30AM (#15566379)
You seem to be implying that I prefer all unit tests and no integration or system tests. Far from it.

A system test catches the backend API issue. A unit test can demonstrate that my component degrades gracefully if the backend API is not available (because I used a mock to provoke a timeout response).

Re:Write tests. Not too many. Mostly integration by bpicolo on Friday October 27, 2017 @09:19AM (#15567974)
There are plenty of systems out there that can't degrade particularly gracefully.

That said, the big issue with unit tests is they don't test the glue which is where a lot of issues happen. In languages with strong type systems, this is less of an issue.

Unit tests are great when you actually have complex logic with relevant corner cases, but when you're building web apps, 95%+ of your code is just boilerplate data munging

Re:Write tests. Not too many. Mostly integration by kelnos on Friday October 27, 2017 @05:42AM (#15566917)
The problem is that it's almost always possible to achieve a similar or identical number of bugs with lower test coverage, and every test you write has a maintenance cost.

In my experience, the vast majority of test failures (after I've made a code change) end up being issues with the tests themselves, and not with the code change. If you're testing obviously-correct code, that's just more that can spuriously break later and require time and effort to fix and maintain.

Re:Write tests. Not too many. Mostly integration by olavk on Friday October 27, 2017 @05:45AM (#15566937)
I assume you are sarcastic, but cannot figure out what your actual point is. Are you disputing integration tests can find some types of errors which unit testing will not uncover?
Re:Write tests. Not too many. Mostly integration by fnord123 on Friday October 27, 2017 @05:53AM (#15566973)
I read your comment "Because they can find bugs and errors which unit tests cannot." to suggest that unit tests cannot find bugs.

You probably meant "Because they can find bugs and errors that unit tests cannot." to remove the ambiguity.

tl;dr, I am illiterate; but a little change to the original comment could make it easier.

Re:Write tests. Not too many. Mostly integration by hinkley on Friday October 27, 2017 @01:03PM (#15570214)
Except mine had plenty of bugs nobody ever saw because I spotted them while writing the tests...