The approach of Test Driven Development (TDD) is to first write the test, see that it fails by default (i.e., a new test succeeds by failing), then write the function to pass the test.
In this way, testing becomes not an afterthought, but the very core of your development methodology.
Because you may be developing a function (method) before you have implemented the objects upon which it operates, most TDD frameworks also provide a facility for generating "mock" objects, which will return expected results before their classes are actually implemented.
I personally recommend Google Test and Google Mock.