8 ms·
I don't know (and don't care) if this makes your unit tests faster, you shouldn't write code like that. He took something that should be simple and made it real
by schmrz 13y ago
I don't know (and don't care) if this makes your unit tests faster, you shouldn't write code like that. He took something that should be simple and made it really complicated. The execution time of your tests shouldn't dictate how you will design and write your application. Especially if it makes things harder to maintain and understand.
Edit: I love tests and they should be fast so that you can run them every time before pushing your changes but as I said they shouldn't dictate how you design and write your application.
- orend 13y agoThe point here is not that the tests execution time should dictate the design. On the contrary, the idea of this post was to stress the importance of good design, and that fast tests are just a side effect of it. Now, you might disagree with me on what constitutes good design but that's a different issue.
- schmrz 13y agoDon't get me wrong, I agree with the idea that you should look at the root cause of why your tests are slow instead of trying to "fix" the tests. I just feel that what you demonstrated is bad design. So you ended up with bad design and fast tests.
- regularfry 13y agoTDD advocates would disagree.
- schmrz 13y agoI'm not sure I follow. What exactly would TDD advocates disagree on?
- tieTYT 13y agoI think he is replying to this: > ... your tests shouldn't dictate how you will design and write your application I know that's not your whole quote and a lot of context is lost in that "...", but I think that's what he's replying to.
- regularfry 13y agoPretty much, yes. TDD would say that if testing is painful, changing your design to take away that pain will leave you with a better design overall.