Coding Practice: What should I do if my lines of unit test code is greater than the lines of code being tested?
This is a good sign. You should expect to have a code-to-test ratio of 1:2 (i.e. twice as much unit test code as actual code). If you don’t have more test code than production code, then you are probably too light on tests.
Quote:
“By necessity each unit of functionality has at least one test. For many types of functionality, one test is not enough. Tests that test only the ‘happy path’ of your code are easy to write. Unfortunately, these tests often do not tell the whole story.”
– James Bender
Application:
Keep in mind, when you are doing TDD, you will create at least one “happy path” and one boundary unit test per class method, so from the very outset you will have more test code than production code. As you add functionality, you will think of additional functional and non-functional requirements to represent as unit tests and additional boundary tests which will result in a code-to-test ratio of around 1:2.
References:
Professional Test Driven Development with C#