I suggested that he refactor his code to make unit tests possible and then to add unit tests.
He argued against adding the tests. Here are some of his arguments against unit testing along with my responses.
Against Unit Testing | Responses. |
---|---|
You're making the code more complex! You want me to add factories and abstract classes and so on, just so things are more testable. You're asking me to rewrite a lot. I don't want to re-write code that already works. | This is true. Some things got more complex. But see, writing code to become more testable, has the side effect of making the code more modular. And making code more modular is good. |
You have to learn a lot to get going. New frameworks, new tools, new concepts. All of these new things make things more confusing and complex. This might be a fad that we forget about in a month or two. |
Learning is part of the job of being a programmer. It's one of my favorite parts. Maybe the framework and tools we use for testing will change over time. But you can't argue that the concepts are a waste to learn about. Even if you don't want to use the concepts, it's cool to understand and learn. No? |
Writing test code is a pain in the neck. You are doubling my work load with no increase in production! |
I disagree. Writing test code is fun. |
I've already tested it. Trust me, it works. Why write a test? |
Writing unit tests allow someone else (even a dumb machine) to test your code. Otherwise, if I have to change your code, I'll have to stop by your desk and you'll have to tell me about it. Isn't that a waste of your time? |
No comments:
Post a Comment