Home > Archive > Extreme Programming > February 2005 > How can I use nunit in this case?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How can I use nunit in this case?
|
|
| verulam@bigfoot.com 2005-02-03, 3:57 am |
| Hi
Say I've got a method in an object that takes a custom data transfer
object and uses a data layer to save that information to a database.
How on earth do I use nunit to unit test that method?
It just doesn't make sense, I can't possibly write unit tests to
contain all possible values in the dto so I would have to choose a
sub-set of choice information.
Do I have to stub the dto and compare the values in the dto passed in
and the values sent to the data layer? If I look and see what's in the
database it could have been the data layer that messed up.
any hints would be greatly appreciated
| |
| Ron Jeffries 2005-02-03, 3:57 am |
| gOn 2 Feb 2005 15:08:20 -0800, verulam@bigfoot.com wrote:
>Say I've got a method in an object that takes a custom data transfer
>object and uses a data layer to save that information to a database.
>How on earth do I use nunit to unit test that method?
>
>It just doesn't make sense, I can't possibly write unit tests to
>contain all possible values in the dto so I would have to choose a
>sub-set of choice information.
>
>Do I have to stub the dto and compare the values in the dto passed in
>and the values sent to the data layer? If I look and see what's in the
>database it could have been the data layer that messed up.
>any hints would be greatly appreciated
Please give a few examples of things that might break that you want to
test for in this situation.
--
Ron Jeffries
www.XProgramming.com
I'm giving the best advice I have. You get to decide if it's true for you.
| |
| Shane Mingins 2005-02-03, 3:57 am |
| <verulam@bigfoot.com> wrote in message
news:1107385700.569880.5130@l41g2000cwc.googlegroups.com...
> Hi
>
> Say I've got a method in an object that takes a custom data transfer
> object and uses a data layer to save that information to a database.
What do u mean by custom DTO? Are you using one DTO to carry data for any
and all business objects?
I am curious to how you have the system layered? For example we are using
the DTO pattern. We also have DTO Assemblers that create DTOs from business
objects and vice versa. Our data layetr (which uses Hibernate) only saves
buiness objects.
Regards
Shane
--
"I could be wrong. I could be right." -- Rise by PIL
| |
| Robert C. Martin 2005-02-04, 8:56 pm |
| On 2 Feb 2005 15:08:20 -0800, verulam@bigfoot.com wrote:
>Hi
>
>Say I've got a method in an object that takes a custom data transfer
>object and uses a data layer to save that information to a database.
>How on earth do I use nunit to unit test that method?
>
>It just doesn't make sense, I can't possibly write unit tests to
>contain all possible values in the dto so I would have to choose a
>sub-set of choice information.
Why do you need all possible values? Does the method use those values
to make particular decisions? If so, you should have tests that check
that each decision is made correctly, in all possible directions; but
not for all possible values.
As a simple example, if you have this statement:
if (x>0)
you should have a test when x is greater than zero, and a test when x
is not greater than zero. But you don't need a test for all possible
values of x.
>Do I have to stub the dto and compare the values in the dto passed in
>and the values sent to the data layer?
I would think that would be a stub of the data layer, not a stub of
the DTO; but - yes - that's one way to cut at it.
>If I look and see what's in the
>database it could have been the data layer that messed up.
I would not look at the database. I'd stub the data layer and make
sure that the correct data was getting there. You can trust the
database to work correctly in most cases. (You should have a few
critical tests that go all the way to the database just to make sure
that it's connected etc.)
-----
Robert C. Martin (Uncle Bob) | email: unclebob@objectmentor.com
Object Mentor Inc. | blog: www.butunclebob.com
The Agile Transition Experts | web: www.objectmentor.com
800-338-6716
"The aim of science is not to open the door to infinite wisdom,
but to set a limit to infinite error."
-- Bertolt Brecht, Life of Galileo
|
|
|
|
|