Chief Executive Officer of Orange & Bronze Software Labs which specializes in enterprise software development and Agile Transformation.
Wednesday, June 20, 2018
Teach TDD Students How to *Avoid* Writing Tests
When teaching TDD, I also teach my trainees how to avoid having to write tests. Surprised?
First, I teach them to recognize when a method or scenario is too simple to merit a test - e.g. getters & setters, is-null validation, is-between-some-numbers validation, well-known library behavior, etc.
Then, I show them how to refactor their code to make it simpler - immutable fields, constrained parameters, use of well-known libraries. I get my demo code to a point where most methods don't need tests. Sometimes I even show that after some refactoring, you should delete some tests that are no longer valuable, since all code carries a maintenance cost, including test code.
No comments:
Post a Comment