Srinivas Charan Mamidi
Srinivas Charan Mamidi

Reputation: 331

Is refactoring applicable to test code

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

Answers (2)

Ped7g
Ped7g

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

Mik378
Mik378

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

Related Questions