I am learning TDD using c#, as far as I know test should drive the development, that is first write a failing test after write the bare minimum code to pass the test then do refactoring.
But it is also said that "Program to Interface, not Implementation", so write an interface first. This is where my confusion starts, If I am writing Interface first then it is violating two things
The code that is written for interface is not driven by test.
It is not the bare minimum obviously i can write it with a simple class.
Should I start by writing tests for interface also ? without any implementation what am I going to test ?
If this question sounds silly sorry for that, but I am utterly confused. May be I am taking things too literally.
interface
for everything. Aclass
also provides an interface, because you can hide implementation details inprivate
variables.contract
. This could be in the form of an abstract class, for example, though it shouldn't be a virtual class/method because you shouldn't be able to instantiate it.