473,403 Members | 2,354 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,403 software developers and data experts.

are there guidlines for NUnit friendly classes?


Hi,

We are going to invest in testing and I wonder are there any guidelines
to design NUnit friendly classes?
Should I consider at all ease of use in unit testing when designing my
classes?

Thanks in advance.

Note that I am using NUnit to test my classes I am not doing TDD for now.
Nov 16 '05 #1
3 1603
Julia,

As long as you can call the methods on your classes somehow (and
configure the environment so that you can make the calls), then you
shouldn't have a problem.

Your NUnit tests are not coded into your classes (well, they could, but
they shouldn't). Rather, you should have separate classes which are your
test cases and then they call your classes you are trying to test.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Julia" <co********@012.net.il> wrote in message
news:uP*************@TK2MSFTNGP15.phx.gbl...

Hi,

We are going to invest in testing and I wonder are there any guidelines
to design NUnit friendly classes?
Should I consider at all ease of use in unit testing when designing my
classes?

Thanks in advance.

Note that I am using NUnit to test my classes I am not doing TDD for now.

Nov 16 '05 #2
Wow it was fast...

Thanks.

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ef**************@TK2MSFTNGP12.phx.gbl...
Julia,

As long as you can call the methods on your classes somehow (and
configure the environment so that you can make the calls), then you
shouldn't have a problem.

Your NUnit tests are not coded into your classes (well, they could, but they shouldn't). Rather, you should have separate classes which are your
test cases and then they call your classes you are trying to test.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Julia" <co********@012.net.il> wrote in message
news:uP*************@TK2MSFTNGP15.phx.gbl...

Hi,

We are going to invest in testing and I wonder are there any guidelines
to design NUnit friendly classes?
Should I consider at all ease of use in unit testing when designing my
classes?

Thanks in advance.

Note that I am using NUnit to test my classes I am not doing TDD for now.


Nov 16 '05 #3
Yes, you should consider ease of testing when you design your classes.

One thing you should think about is whether you can design classes that
you can decouple from the environment they run in.

For example, we have a business layer that calls a data layer to fetch
data from the database. However, I specifically designed the business
layer so that you could (using static properties and methods) "plug in"
a phoney data layer. That way I can write NUnit tests that create
phoney data layer objects to return canned data, "plug" them into the
business layer, then test the business layer. I do this because trying
to coordinate NUnit tests with "test" databases and "test" XML files,
and other "test" environments is a royal headache.

Ideally, you will have classes that do not in any way rely on
databases, files, or other environmental items or resources. However,
as in the case of my business layer, that's not always possible, so at
least provide a "back door" through which you can feed phoney data.

If you manage this, then the goal is to make your (NUnit testable)
business layer classes fat and your (difficult to test) data access and
UI layer classes as thin as possible. This maximizes your easy-to-test,
environment-independent logic and minimizes your difficult-to-test,
environment-dependent logic.

Nov 16 '05 #4

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

Similar topics

6
by: Peter Rilling | last post by:
My development team is using VS.NET with VSS integration. They are able to check in and out from within VS.NET. We also use NUnit for testing our libraries. Currently our entire solution is...
2
by: Sky Kim | last post by:
Hi, all. I've know NUnit for a while, now I try to use it. Most of application I develope is data base driven. I want to test data layer most with may input and checking the result, then compare...
3
by: Finn J Johnsen | last post by:
Hi Dow do I get ndoc to ignore classes flagged with the attribute? Thanks, Finn Johnsen
3
by: Ole Hanson | last post by:
Hi I am trying to engineer a way of testing that my logging framework is capable of writing to my eventlog. I want to include this test in my already existing NUnit tests - but I'm a little low...
5
by: Naveen Mukkelli | last post by:
Hi all, How can we use "NUnit" in socket programming. I mean, I'm writing a server program which accepts connection requests from the clients. I want to test the number of clients whenever a...
4
by: Mark | last post by:
I'm building some NUnit tests for the business classes in my ASP.NET application. Some of the business classes use Session to store information. NUnit does not generate a Session, so the code...
1
by: MD | last post by:
Hello I work in a .NET environment and I am about to create a development strategy. As part of this I am looking at implementing a testing tool to fit in with an iterative approach and NUnit...
6
by: tchaiket | last post by:
Hey all, I'm using NUNIT to test our classes. However, I don't want to hard code test data into the NUNIT classes. For example, to test adding a new Client, I don't want to hard code the...
5
nikpreek
by: nikpreek | last post by:
Hi All, This is my first post, I've been finding lots of solutions from this forum. Thanks to all who helped (and ones who asked questions). I have a strange problem. I'm having a console app and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.