4

I'm an iOS developer and I cringe when I read job specs that require TDD or excessive unit testing. By excessive I mean demanding that unit tests need to written almost everywhere and using line coverage as a measure of success. I have many years of experience developing iOS apps in agencies and startups where I needed to be extremely time efficient while also keeping the code maintainable. And what I've learned is the importance of DRY, YAGNI and KISS over excessive unit testing. Sadly our industry has become obsessed with unit tests. I'm of the opinion that unit tests have their place, but integration and e2e tests have more value and should be prioritised, reserving unit tests for algorithmic code. Pushing for unit tests everywhere in my view is a ginormous waste of time that can't ever be repaid in quality, bug free code. Why? Because leads to making code testable through dependency injection and 'humble object' indirection layers, which increases the LoC and fragments code that would be easier to read over different classes. Add mocks, and together with the tests your LoC and complexity have tripled. 200% code size takes 200% the time to maintain. This time needs to be repaid - all this unit testing needs to save us 200% time in debugging or manual testing, which it doesn't unless you are an absolute rookie who writes the most terrible and buggy code imaginable, but if you're this terrible writing your production code, why should your tests be any better? It seems that especially big corporate shops love unit tests. Maybe they have enough money and resources to pay for all these hours wasted on unit tests. Maybe the developers can point their 10,000 unit tests when something goes wrong and say 'at least we tried'? Or maybe most developers don't know how to think and reason about their code before they type, and unit tests force them to do that?

Comments
  • 4
    Just stop complaining and write the tests
  • 3
    This post needed unit tests, maybe then it wouldn't be so unreadable
  • 0
    You definitely need unit tests for everything math related.
    Then you will at least not write about a 200% save in debugging time anymore.

    Would be real awesome to travel back in time while debugging that well-tested code though...
  • 0
  • 1
    So you are telling us you don't want automated tests in, let's say, self driving cars?
  • 0
    @SuspiciousBug no, I'm not. I don't work on self-driving cars. I make consumer apps. No one will die if there is a bug. Besides, for system-critical software (e.g. automotive, medical devices) unit and other automated tests are not sufficient.
  • 0
    @gingrnut "No one will die if there is a bug" - Your quality standards are just sad
  • 0
    @MrMarco that's not my quality standard. Consumer software has bugs - period. The questions is, how many are acceptable for your project. My experience is that it is possible to write code for mobile apps with sufficient quality WITHOUT any unit tests (I have been lauded many times for bug free code) - and saving a lot of time this way.
  • 0
    @gingrnut You have less than 5 years experience right?
  • 0
    @MrMarco more than 10
  • 0
    @gingrnut Then this is a problem
  • 0
    what is?
Add Comment