TDD and private methods/classes

  • Thread starter Thread starter Simon Woods
  • Start date Start date
S

Simon Woods

Hi

I'm still trying to get my head around how to do TDD.

I have a situation where I have a set of classes which build a tree
which contains nested (subselect) SQL statements. The tree is completely
internal to my project and there is no need to make it public in any
way. The logic is pretty complex (for me anyway) and so I want to be
able to test it with a variety of test cases. The tree generates SQL
which is then used to create a dataset and this is the public object.

However, I understand that TDD only tests the public interfaces ... but
that's not good enough as the dataset will be other things are well
(e.g. formatting values etc)

So my question is, what is the TDD way for testing my SQL generation. At
the moment I have included a public Test Class which instantiates and
builds my SQL tree thus allow me to see how it is behaving, but I'm not
sure that this is the right/best way.

Could someone explain alternative strategies which are perhaps "more TDD".

Thanks

Simon
 
You can use TDD on private methods. Just be aware it involves using
reflection , and hence strings in places, so if you refactor your code, it's
hard to keep the tests in sync.
 
Back
Top