473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

TDD and private methods/classes

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
Jun 27 '08 #1
2 1059
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.
"Simon Woods" <si*********@hotmail.comwrote in message
news:u7**************@TK2MSFTNGP05.phx.gbl...
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
Jun 27 '08 #2
Thanks Bill

So is there a better way of architecturing/thinking abnout it?

S

Bill McCarthy wrote:
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.
"Simon Woods" <si*********@hotmail.comwrote in message
news:u7**************@TK2MSFTNGP05.phx.gbl...
>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
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rajesh Garg | last post by:
Can we have private constructors and destructors? IF yes what is the use of such constructors or destructors.....in the sense where can these be implemented in a system................. I have...
5
by: David Rubin | last post by:
Is there ever a good reason to declare private non-virtual member functions in a class definition? As far as private virtual function are concerned, my understanding is that, if you have a...
1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
10
by: Martin Vorbrodt | last post by:
Example code in one of my books intrigues me: class B { public: B* Clone() const { B* p = DoClone(); assert(typeid(*p) == typeid(*this)); return p; }
10
by: Abelardo Vacca | last post by:
Hi, The title sums up the question pretty much. I would like to access all private members of a class including the private members of its base classes.( I already have the ReflectionPermission )...
12
by: Noah Roberts | last post by:
I'm using a simple unit test architecture I found in "Thinking in C++". I just decided I wanted to place some member functions out from public into a protected scope. Problem is that my tests want...
7
by: Alex Vinokur | last post by:
I tried to build program with partial implementation. However a linker generates errors. Is there any approach that enables to use partial implementation for similar purposes? ------ foo.cpp...
86
by: jopperdepopper | last post by:
Hi, finally giving php 5 a go, and going over the new approach to classes. Can someone clarify the public, private and protected to me? I quote the php manual: "The visibility of a property or...
6
by: earthwormgaz | last post by:
Is the following legal? class Outer { class Inner { private: Inner() { } };
8
by: David Veeneman | last post by:
Should a member variable be passed to a private method in the same class as a method argument, or should the method simply call the member variable? For years, I have passed member variables to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.