Unit Testing

D

D. Yates

Hi,

In an effort to improve my own code and try to teach others that I work with
that unit testing IS MANDATORY. I'm interested in examples of unit testing
that other people are using.

How many folks rely on NUNIT?

Do you create a testing class per application, per class, per assembly to
exercise your code?

Do you know of any links that show examples of how the "Agile process"
incorporates unit testing into its process?

Know of any code in source forge that contains testing code?

How have to standardized your testing classes/code so that it "looks" and
"feels" the same and isn't totally confusing to outsiders that may have to
maintain your code?

Do you embed your test class into the same assembly as the class it tests?
I like this idea because it keeps someone else from breaking your code (at
least making sure it compiles) when they come in to do a "quick" change.

I would appreciate any links or book recommendations on the subject.

Thanks,
Dave
 
J

Jon Skeet [C# MVP]

D. Yates said:
In an effort to improve my own code and try to teach others that I work with
that unit testing IS MANDATORY. I'm interested in examples of unit testing
that other people are using.

How many folks rely on NUNIT?

Do you create a testing class per application, per class, per assembly to
exercise your code?

Per class, usually.
Do you know of any links that show examples of how the "Agile process"
incorporates unit testing into its process?

I suspect pretty much any description of Agile coding is likely to
mention unit testing. I don't have any specific links off-hand though.
Know of any code in source forge that contains testing code?

Pretty much any test tool project will have test code. Other examples
are Spring and Hibernate - both Java projects, but I'd expect their
..NET equivalents to have test clode too.
How have to standardized your testing classes/code so that it "looks" and
"feels" the same and isn't totally confusing to outsiders that may have to
maintain your code?

We tend to use m_subject as a member variable which refers to an
instance of the class under test, for starters.
Do you embed your test class into the same assembly as the class it tests?
I like this idea because it keeps someone else from breaking your code (at
least making sure it compiles) when they come in to do a "quick" change.

No, we use a different project in the same solution. You don't really
want test code bloating the release DLL - especially if you embed test
data files. On the other hand, if you don't mind a little bit of extra
space and don't mind the possibility of people finding your tests, it's
a great way to allow easy testing of internal members too.
 
N

nthomson

I would agree with Jon, we take a similar approach.

Use NUnit, test per class and keep our test classes seperate from the
main application.
 
D

D. Yates

Jon,

Thanks for your response.

How do you handle application testing provided that your unit testing
passes? Do you just use human testers or is your testing automated in
anyway?

Dave
 
D

D. Yates

Angus,

Thanks for your response.

I noticed that on the test driven site they reference a book called
"Test-Driven Development in .NET". Do you own this book? If so, what are
your thoughts as to its worth. In other words, do you refer to it often or
almost never.....

Thanks,
Dave
 
C

Cool Guy

[...]
No, we use a different project in the same solution. You don't really
want test code bloating the release DLL - especially if you embed test
data files. On the other hand, if you don't mind a little bit of extra
space and don't mind the possibility of people finding your tests, it's
a great way to allow easy testing of internal members too.

Still, you can use conditional compilation to exclude test code from
release builds.
 
A

A Miller

I noticed that on the test driven site they reference a book called
"Test-Driven Development in .NET". Do you own this book? If so,
what are your thoughts as to its worth. In other words, do you refer
to it often or almost never.....


That's not a book I know. One I can recommend is 'Working Effectively
with Legacy Code' by Michael Feathers - which gives lots of examples of
how you can implement TDD with your currently untested code.

http://www.amazon.com/gp/product/0131177052/qid=1134153763/sr=1-1/ref=sr
_1_1/102-3508174-2971300?s=books&v=glance&n=283155


Angus Miller
 
J

Jon Skeet [C# MVP]

D. Yates said:
Thanks for your response.

How do you handle application testing provided that your unit testing
passes? Do you just use human testers or is your testing automated in
anyway?

We have some automated tests and some manual tests. Obviously, some
types of UI are easier to test than others - and many integration level
tests can be done at the web service level rather than at the visible
UI level.
 
J

Jon Skeet [C# MVP]

Cool Guy said:
Still, you can use conditional compilation to exclude test code from
release builds.

Yes, but then you're not testing what you're releasing. There's a
definite appeal to running unit tests on the *real* code.
 
J

Jon Skeet [C# MVP]

A Miller said:
That's not a book I know. One I can recommend is 'Working Effectively
with Legacy Code' by Michael Feathers - which gives lots of examples of
how you can implement TDD with your currently untested code.

http://www.amazon.com/gp/product/0131177052/qid=1134153763/sr=1-1/ref=sr
_1_1/102-3508174-2971300?s=books&v=glance&n=283155

While I haven't read that one myself, I believe it's the one my team
leader absolutely swears by. It's sort of "testing in the real world,
where things get icky."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top