Reputation: 331
I am learning to use test driven development. As a part of this I need to write few modules.
My question is: will refactoring also be applicable to test code?
Upvotes: 0
Views: 49
Reputation: 16626
A good public API usually decouples well from implementation, so at those lucky moments the refactoring of implementation should cause none or very small changes to tests (and that's sort of proof of good API design).
But I often test also some stuff from inside, when the public API is of high abstraction, doing lot of processing and algorithms in single call, then refactoring code often hits the tests too and requires similar amount of work.
Upvotes: 1
Reputation: 22191
Tests are code and are the pillars of your application.
So yes, you should refactor your test code with the same care you take for refactoring production code.
Upvotes: 2