4 ms·
I totally understand writing tests on professional projects and on projects that I am working with others, but for my side projects, I could never. I don't feel
by mewpmewp2 2y ago
I totally understand writing tests on professional projects and on projects that I am working with others, but for my side projects, I could never. I don't feel like I have lost anything by not writing tests in my side projects.
My issue with tests in my side projects is that it kills my flow. I need to actively iterate on the code that matters and feel out the results. At what point should I be writing tests?
I can only think of a point where I am certain this is where I am going to stay at and then I write some sanity regression tests.
- kragen 2y agoSometimes that happens, because the difficulty is not in getting it to do what you want, but figuring out what you want. That's the main theme of my top-level comment; I'm interested to hear what you think. https://news.ycombinator.com/item?id=43597869 https://news.ycombinator.com/item?id=43597869
- simonw 2y agoIt is deeply unintuitive that writing tests for personal / side projects would be worthwhile. I found that my productivity on those projects increased dramatically when I adopted the same testing regime I had previously used in my day-job with an engineering team distributed across multiple continents. That's why I wrote that talk! "At what point should I be writing tests?" Once the code does the right thing, and you want it to keep doing the right thing. Don't try to write the tests first, that's a productivity anti-pattern.
- pydry 2y ago>Don't try to write the tests first, that's a productivity anti-pattern. Uh, this isnt great advice. If you're spiking then sure, dont write a test at all. If you're writing production code you should have a clear picture of what it should do before you start. Your test should validate that so it makes sense to write that next. It serves as a natural transition from your requirement to youe code. Ive written a lot of code without tests at all for good reasons and a lot of tests before code but ive never witnessed a good reason to write a test after writing the code. At best it is almost as beneficial.
- simonw 2y agoI stand by what I said. It's unconventional advice and goes against industry "best practice" - plenty of people will imply that if you're not writing your tests before your implementation you're "doing it wrong". I think that advice causes people to skip writing tests entirely and feel guilty about it, because often writing test first really does slow down your development process substantially in many cases. My experience is that writing tests after the implementation gives me all of the value of writing the test before but takes genuinely about half the amount of time. You can't do snapshot testing if you force yourself to write the tests first!
- pydry 2y ago>I think that advice causes people to skip writing tests entirely and feel guilty about it I dont think guilt or lack thereof is a good rationale for any development practice. It actually annoys me that people so often add a moral dimension to development practices. The only question that matters is "does it work well?" >You can't do snapshot testing if you force yourself to write the tests first! Yes you can you can write the whole test, you just cant lock the snapshot artefact(s) in until you've written the code.