I have a hobby side project, which I’m quite close to shipping. I started off going for 90% unit tests, but since I’m hacking alone, it ends up taking a bunch of time to keep the tests up to date.<p>Im thinking of keeping all the old unit tests, but switching to a full integration E2E testing system. This way, I can just text features as opposed to code paths.<p>By day I work at <insert tech giant here>, and I would never push up code without it being unit tested, so it feels a little painful to ship with only integration tests.<p>Thoughts? For those of you who’ve shipped small projects, what tests did you find had the most benefit?
Unit tests help developers, integration tests help logic.<p>This can annoy folks, but the straight forward truth is that integration tests cover the unit as well as the whole, so if time is limited, they should 100% be the priority as they bring more value.<p>That said, I love making sure that my code is well unit tested and I build TDD where I can to make that happen. Im not dismissing the value of unit tests, but when you have to make a choice, for me, Integration tests win.
This applies to my MVPs too:<p>Almost none.<p>I'll write unit tests for functions containing complicated logic that I can't quickly evaluate correctness. This probably amounts to something like 0.01% test coverage.<p>As a project unfolds, I'll write proper tests for things that I'm terrified of breaking. For example, if I was changing my charging algorithm, I'd probably put proper test coverage around that segment of my codebase.
My side projects can go months without and update. As such I try to do unit tests for my models, controllers, and middleware.<p>I make sure that stubs exist for functional and end to end tests. That way when I do see bugs come in from sentry I can quickly write tests into the right layer. Usually they are unhandled failures on external requests.
I write tests only for tricky pieces of unsafe code, most of my projects are tested the old fashion way.<p>When an error state arises I fail gracefully and move on. The most important part in most my projects is just to keep on chugging.