HACKER Q&A
📣 antholeole

What kind of tests do you write for your side projects?


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.

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.

By day I work at , and I would never push up code without it being unit tested, so it feels a little painful to ship with only integration tests.

Thoughts? For those of you who’ve shipped small projects, what tests did you find had the most benefit?


  👤 earpwald Accepted Answer ✓
Unit tests help developers, integration tests help logic.

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.

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.


👤 leros
This applies to my MVPs too:

Almost none.

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.

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.


👤 simplecto
My side projects can go months without and update. As such I try to do unit tests for my models, controllers, and middleware.

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.


👤 errantmind
I write tests only for tricky pieces of unsafe code, most of my projects are tested the old fashion way.

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.


👤 visox
None but eventually integration tests