3 ms·
Here's my slider, which is working really well at my startup. 1. Speed trumps reliability Also, manual testing of stable features is wasteful. For things at t
by MartinCron 16y ago
Here's my slider, which is working really well at my startup.
1. Speed trumps reliability Also, manual testing of stable features is wasteful.
For things at the business logic layer, I have a suite of (many) unit tests that verifies that all of the domain objects do the right thing. They are small, fast, don't break when I refactor the code (automated refactoring tools FTW) and easy to work with.
I have another set of integration tests which talk to some external services (twitter, fb, etc.) these are slow and aren't as core to the business logic.
I have yet another set of tests that test the real database (I use simple test doubles in the unit test layer).
Whenever we update code in our source control system, a TeamCity server builds, runs the unit tests, integration tests, data tests, and then does a zero-downtime deployment to our production server. Immediately after that, we run a handful of tests against the server to make sure that the server isn't totally broken.
This sounds like a lot of work, and it is, but it makes us able to deliver so much more quickly than any alternatives. Continuous deployment means that no time is wasted on manually pushing code to servers. Also, it means that the changes made are the smallest and safest changes possible.
And, most importantly, it means that you don't have to spend a lot of time manually testing existing stable features just to get a baseline of reliability.
Do I strive for 100% code coverage of all classes? No. There's a continuous cost-benefit analysis going on. If something is tricky or would create brittle tests, I don't have automated tests for it. If something is really core (e.g. proper enforcement of game rules) I sure as hell am going to write tests for it. Right now, I'm at 72% test coverage.
Trust your common sense here. It's not all-or-nothing. You can get meaningful speed-and-stability-improving-value out of having some tests without having to test every single line of code.