3 ms·
TDD came out of agile programming which is also more concerned with fast delivery than NASA-style correctness. It's a tool supposed to help you go faster. If y
by mbrock 10y ago
TDD came out of agile programming which is also more concerned with fast delivery than NASA-style correctness. It's a tool supposed to help you go faster.
If you want an agile unit test suite, it has to run in seconds, not minutes. TDD will make this very clear. If you have problems with the test suite being slow, you have to fix it!
A test suite that developers actually like to run is an enormous value, maybe especially for new team members. It gives you confidence when making changes and adding features.
A basic purpose of TDD is to make it obvious when code is hard to test, so that you're always encouraged to write units that can be unit tested without difficulty. That's a skill that takes some practice and learning, and you need to pay real attention to it. When your team understands how to do it, that's when the test suites start to make real sense, and it becomes pretty much a pleasure to write the tests.
I don't know about being a consultant but I'd like to say that comprehensive testing is a necessary standard part of professional programming just like serious manufacturers verify the quality of components. It can also reduce the stress and anxiety of developers which leads to a better work environment and better quality.
As a coder in a team with half legacy and half well tested code, I know it was a delight to work on the modules developed according to good TDD practice.
- gbog 10y agoTest suite being slow: you shouldn't have to run all the tests all the time, just bask the code where you are working, run the full suite and take note of the failed tests, then just run constantly these and a few more while coding. Then run again the full suite before going to lunch.
- mbrock 10y agoThat gets annoying when you're working on something that touches several parts, and if your tests are slow altogether they'll probably be slow enough to be tedious even when running just 10% of them.
- collyw 10y ago"If you want an agile unit test suite, it has to run in seconds, not minutes. TDD will make this very clear. If you have problems with the test suite being slow, you have to fix it!" To me this is TDD going putting the cart before the horse. Test driven design. Except you design so that the tests run fast. And the application design, is that actually considered?
- mbrock 10y agoOf course it's considered. It's not difficult to write fast unit tests if you follow the principles that make them fast. A fast test suite has lots of value, and doesn't conflict with good design—on the contrary.
- collyw 10y agoThe Rails guy wrote about this. http://david.heinemeierhansson.com/2014/tdd-is-dead-long-live-testing.html http://david.heinemeierhansson.com/2014/tdd-is-dead-long-liv...
- mbrock 10y agoI disagree with him but I'm also not a TDD fanatic in any way. Still, I find it useful to structure my code as units with few dependencies and minimal side effects, which makes unit testing a very appropriate methodology. I don't always do tests first, but I think as a methodology it's as reasonable as anything.