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

Unit testing

Hi folks,

I've been looking at unit testing frameworks (csUnit, NUnit, etc) and have
gathered some info on them (see the older thread on c# 2004). My question is
this: how do they work with windows forms?

All the samples I've seen are for trivial testing, such as making sure a
property sets it's value correctly. How would I go about testing, for
example, a custom control? All my testing seems to be visual (i.e. compile,
run, see if it looks okay).. am I missing something?

It seems to me that unit testing frameworks are of little use here.

Pete
Nov 15 '05 #1
5 2840
http://www.nunit.org/default.htm is free and pretty good. And you can
write your test cases in c# which is natural.

--
William Stacey, DNS MVP

"Pete" <pv*****@gawab.com> wrote in message
news:gJ******************@newsfep2-gui.server.ntli.net...
Hi folks,

I've been looking at unit testing frameworks (csUnit, NUnit, etc) and have
gathered some info on them (see the older thread on c# 2004). My question is this: how do they work with windows forms?

All the samples I've seen are for trivial testing, such as making sure a
property sets it's value correctly. How would I go about testing, for
example, a custom control? All my testing seems to be visual (i.e. compile, run, see if it looks okay).. am I missing something?

It seems to me that unit testing frameworks are of little use here.

Pete

Nov 15 '05 #2
Hi,

William Stacey wrote:
http://www.nunit.org/default.htm is free and pretty good. And you
can write your test cases in c# which is natural.


Did you actually read my message (I mentioned nunit)? My problem is how to
add test cases to windows forms controls (custom controls of my design) in a
useful way.

All the unit testing frameworks (for c#) work in virtually the same way.
NUnit is not unique, or even necessarily the best. Coupled with the fact
that their website seems to completely lack any info on typical/advanced
usage patterns, that link is not too useful to me.

-- Pete
Nov 15 '05 #3
Pete wrote:
Hi folks,

I've been looking at unit testing frameworks (csUnit, NUnit, etc) and
have gathered some info on them (see the older thread on c# 2004). My
question is this: how do they work with windows forms?

All the samples I've seen are for trivial testing, such as making
sure a property sets it's value correctly. How would I go about
testing, for example, a custom control? All my testing seems to be
visual (i.e. compile, run, see if it looks okay).. am I missing
something?

It seems to me that unit testing frameworks are of little use here.


The general idea is to put as little actual functionality in the GUI layer
as possible. Instead factor out the "meat" of the application into separate
classes which have no knowledge of the GUI layer. These classes can then be
tested using a unit testing framework.

--
Arild Fines

http://ankhsvn.tigris.org
A Visual Studio .NET Addin for the Subversion version control system.
Nov 15 '05 #4
Hi William (fellow MVP I suppose?),
Well it can still be usefull. A form is just a class right. You can't test the visual look of the form easily, but you can test its function. You can create an instance of a form, plug in test data or set control values, hit
buttons and read results from text boxes, etc. So you can test form
function and exceptions, and if things are visable or other properties on
the form/controls, etc.
A form is not just a class - it is also a window and therefore requires a
message pump to work. To the best of my knowledge, the message pump is
implemented in the Application class, so you will probably need to
instantiate one to run a form as a form and as not just a class.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"William Stacey" <st*****@mvps.org> wrote in message
news:up**************@TK2MSFTNGP10.phx.gbl...
Did you actually read my message (I mentioned nunit)? My problem is how to add test cases to windows forms controls (custom controls of my design)

in a
useful way.
Sorry Pete, I must have only thought I read your post. My mistake.
All the unit testing frameworks (for c#) work in virtually the same way.
NUnit is not unique, or even necessarily the best. Coupled with the fact
that their website seems to completely lack any info on typical/advanced
usage patterns, that link is not too useful to me.


Well it can still be usefull. A form is just a class right. You can't

test the visual look of the form easily, but you can test its function. You can create an instance of a form, plug in test data or set control values, hit
buttons and read results from text boxes, etc. So you can test form
function and exceptions, and if things are visable or other properties on
the form/controls, etc.
--
wjs


Nov 15 '05 #5
Hi,

Arild Fines wrote:
The general idea is to put as little actual functionality in the GUI
layer as possible. Instead factor out the "meat" of the application
into separate classes which have no knowledge of the GUI layer. These
classes can then be tested using a unit testing framework.


Hmm.. I've started using fxcop (which noone pointed out) and it works quite
well. As for unit test, the benefits here seem dwarfed by the effort
involved (my controls are mostly visual, certainly not enough "meat" to
warrant a separate class) so I think I'll pass.

-- Pete
Nov 15 '05 #6

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

Similar topics

4
by: Hugh Cowan | last post by:
Hello, I don't program full-time (anymore), but I do try and stay on-top of the latest technologies and like most are always trying to upgrade my skills and remain current (as much as is...
11
by: rhat | last post by:
Hi Everyone, I've recently been reading some articles about unit-testing in Python , but I am a bit confused: where do I go to get started with this? I tried googling for "unittest" but all I've...
14
by: | last post by:
Hi! I'm looking for unit-testing tools for .NET. Somthing like Java has --> http://www.junit.org regards, gicio
4
by: Peter Rilling | last post by:
Does VS.NET 2005 Professional support integrated unit testing, or is that only with the team system?
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
4
by: Dat AU DUONG | last post by:
Hi, I am new to Unit testing, could you tell me where I could find information (hopefully step by step) and what is the benefit of unit testing. I am a sole developer in a company, therefore I...
5
by: shuisheng | last post by:
Dear All, I was told that unit test is a powerful tool for progamming. If I am writing a GUI code, is it possible to still using unit test? I have a little experience in using unittest++. But...
176
by: nw | last post by:
Hi, I previously asked for suggestions on teaching testing in C++. Based on some of the replies I received I decided that best way to proceed would be to teach the students how they might write...
48
by: Ark Khasin | last post by:
Unit testing is an integral component of both "formal" and "agile" models of development. Alas, it involves a significant amount of tedious labor. There are test automation tools out there but...
5
by: Ben Finney | last post by:
Howdy all, PEP 299 <URL:http://www.python.org/dev/peps/pep-0299details an enhancement for entry points to Python programs: a module attribute (named '__main__') that will be automatically called...
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:
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...
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.