Depending on what language and IDE you are using, you may have some support for "consume-first development".
e.g. in Visual Studio, you could write this line of code:
NewObjectThing foo = new NewObjectThing();
Now, you'll get the red squigglies to indicate that the type or namespace NewObjectThing
cannot be found, and of course the code will not compile.
But if you right-click on it and select Generate -> Class, it will create a new file NewObjectThing.cs in the same folder & namespace as your current code, with an empty class declaration for NewObjectThing
.
Similarly, if you then wrote:
foo.Name = "Fred";
..you could then right-click on Name
and select Generate -> Property to add a property to the NewObjectThing
class (and it would infer the type as string
based on what you were assigning to it).
There are add-on tools like Resharper and CodeRush that add considerable flexibility and power to this process.
Anyway, have a look to see if your IDE supports something similar.
</sarcasm>
TDD's purpose is to help you, not to beat you over the head with regulations :) When @Ikke says interface, BTW, they mean public interface (class methods/properties), not a C# or Javainterface
.dynamic
keyword and a factory function to return your class under test. This allows you to compile and run your test suite, even though methods or whole classes might be missing, and treat binding errors as runtime errors instead of compile time. This lets you write all the tests first, even before writing a single piece of code. There is a minor abstraction cost in your tests, so it is subject to taste.