NUnit and C#

  • Thread starter Thread starter Arne Rasmussen
  • Start date Start date
A

Arne Rasmussen

Hi there!
I'm in the process of learning C# and im going to be a student at a
softwarecompany where they are thinking of using NUnit in their
test/production environment
I've been looking into NUnit myself and it seems pretty easy to use -
however I have a couple of questions that some of you might be able to
answer and some considerations i've done myself - and furthermore i would
like to hear some others experinces with NUnit and its useability.

Is NUnit of that much use when you must follow these restrictions?:

Methods can't have parameters
Methods must be public
Methods has to be of type void

How does one integrate the GUI of NUNit into the VS-IDE espacielley in the
debug-environment - i haven't been able to find any docum. of that ??? -
anybody who has a reciept of how to do that? - or a link?

How are your experinces with NUnit - and is there - in your opinion some
other test-unit that is better or easier to use ???

With thanx in advantage - and pardon my english

Regards
Arne Rasmussen
Denmark
 
Inline.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
Arne Rasmussen said:
Hi there!
I'm in the process of learning C# and im going to be a student at a
softwarecompany where they are thinking of using NUnit in their
test/production environment
I've been looking into NUnit myself and it seems pretty easy to use -
however I have a couple of questions that some of you might be able to
answer and some considerations i've done myself - and furthermore i would
like to hear some others experinces with NUnit and its useability.

Is NUnit of that much use when you must follow these restrictions?:

Methods can't have parameters
Methods must be public
Methods has to be of type void

The point is that you aren't going to test your library's classes directly
by marking them as [TestFixture]. You must write test assemblies that *use*
your classes, calling their methods with correct (or incorrect if you write
a 'must fail' test) values.
 
Richard A. Lowe said:
Inline.

[SNIP]
Is NUnit of that much use when you must follow these restrictions?:

Methods can't have parameters
Methods must be public
Methods has to be of type void

The point is that you aren't going to test your library's classes directly
by marking them as [TestFixture]. You must write test assemblies that *use*
your classes, calling their methods with correct (or incorrect if you write
a 'must fail' test) values.

Yes of course - that sounds logically - but just to bend it in neon for me -
one has to build a test-class for each of the classes one wish to test ???

Regards
Arne Rasmussen
 
NUnit is a pretty good tool for test-driven development. There are others out
there (CSUnit), but I think the general majority use NUnit (although CSUnit and
NUnit are very similar in capabilities).

Arne said:
Hi there!
I'm in the process of learning C# and im going to be a student at a
softwarecompany where they are thinking of using NUnit in their
test/production environment
I've been looking into NUnit myself and it seems pretty easy to use -
however I have a couple of questions that some of you might be able to
answer and some considerations i've done myself - and furthermore i would
like to hear some others experinces with NUnit and its useability.

Is NUnit of that much use when you must follow these restrictions?:

Methods can't have parameters
Methods must be public
Methods has to be of type void

You write test fixture classes, which in turn actually test the implementation
class. Only the fixture class has the 'restrictions' that you describe.

How does one integrate the GUI of NUNit into the VS-IDE espacielley in the
debug-environment - i haven't been able to find any docum. of that ??? -
anybody who has a reciept of how to do that? - or a link?

Just go to Tools, External Tools... and add NUnit-gui to the tools menu. That
is about as 'integrated' as you are going to get. Mind you, there are other VS
plug ins that provide the level of integration that you are looking for (i.e.
they run the tests from within the environment), but they are *very* rough, and
in my opinion, useless. I've yet to find one that works well w/o destroying
the environment.
How are your experinces with NUnit - and is there - in your opinion some
other test-unit that is better or easier to use ???

NUnit (et al.) are good for writing and testing unit tests. Look into fit for
'story tests' which are a higher-level, more comprehensive test fixture
framework. (Note: neither replaces the other -- both NUnit and fit are used:
NUnit (unit tests) test specific functionality points, fit tests a breadth of
functionality).

If you look into fit, be advised that the documentation is virtually
nonexistent, and what there is, is in my opinion, unintelligible -- I just had
to keep playing w/ it until I was able to figure out what was going on. I
guess that is the never-ending penalty of open-source tools...

All of this sums up to: you should seriously consider looking into test driven
development (TDD).
 
NUnit is very useful in a debug environment.

VS can attach to NUnit. In this way you can set break points during unit
tests, single step, etc. You can changed code, recompile without
re-attaching.
 
Whidbey will also have integrating testing similar to nunit but with much
integration. Seems to work pretty good today in beta bits. Until VS 2005,
nunit or csunit are great tools.
 
William Stacey said:
Whidbey will also have integrating testing similar to nunit but with much
integration. Seems to work pretty good today in beta bits.

Can this be script-driven? Interactive testing/debugging is useful, but
batch testing as part of build verification is critical.
 
You don't have to build one for each of your classes, although you could,
but it's a much simpler relationship than that. You simply build a method
that tests some aspect of your class or classes or application. All NUnit
does is run those tests for you (well, at its simplest, that's all it does).

Inside the method or methods you write, things may be as complicated or
simple as you wish. It's totally up to you. You could write one method
that tested EVERYTHING or 10,000 methods that test aspects of one thing. Of
course NUnit has likely been used in more sophisticated ways than this, but
that's the essence of it.

R.

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
Arne Rasmussen said:
Richard A. Lowe said:
Inline.

[SNIP]
Is NUnit of that much use when you must follow these restrictions?:

Methods can't have parameters
Methods must be public
Methods has to be of type void

The point is that you aren't going to test your library's classes directly
by marking them as [TestFixture]. You must write test assemblies that *use*
your classes, calling their methods with correct (or incorrect if you write
a 'must fail' test) values.

Yes of course - that sounds logically - but just to bend it in neon for me -
one has to build a test-class for each of the classes one wish to test ???

Regards
Arne Rasmussen
 
I don't know for sure or have specific examples. However as tests can be
built in a project and run using any kind of pre/post build events you could
come up with, I would think this is very doable. They may have better ways
to do this with MSBuild, but have not looked that deep yet. Cheers!
 
Thank youy very much for talking your time to answer me ...i've been a lot
wiser - and i am going to use NUnit ...by the way ...had a look at CSUnit
....looks to me like a Dolly clone of NUnit ...or is it the other way round
??? ;-)

Regards
Arne Rasmussen
 
Julie said:
NUnit is a pretty good tool for test-driven development. There are others
out
there (CSUnit), but I think the general majority use NUnit (although
CSUnit and
NUnit are very similar in capabilities). [SNIP]
NUnit (et al.) are good for writing and testing unit tests. Look into fit
for
'story tests' which are a higher-level, more comprehensive test fixture
framework.

Do you have a link please ????

(Note: neither replaces the other -- both NUnit and fit are used:
 
Arne said:
Julie said:
NUnit is a pretty good tool for test-driven development. There are
others out
there (CSUnit), but I think the general majority use NUnit (although
CSUnit and
NUnit are very similar in capabilities). [SNIP]
NUnit (et al.) are good for writing and testing unit tests. Look
into fit for
'story tests' which are a higher-level, more comprehensive test
fixture framework.

Do you have a link please ????

http://fit.c2.com/

Cheers,
 
Thanx a lot

Joerg Jooss said:
Arne said:
Julie said:
NUnit is a pretty good tool for test-driven development. There are
others out
there (CSUnit), but I think the general majority use NUnit (although
CSUnit and
NUnit are very similar in capabilities). [SNIP]
NUnit (et al.) are good for writing and testing unit tests. Look
into fit for
'story tests' which are a higher-level, more comprehensive test
fixture framework.

Do you have a link please ????

http://fit.c2.com/

Cheers,
 
Mike said:
Can this be script-driven? Interactive testing/debugging is useful, but
batch testing as part of build verification is critical.

Yes. Both NUnit and fit can be integrated into your build script. We
currently use NAnt to manage the source code checkout/update, build, build
installer, run unit tests, run fit tests.
 
Julie said:
Yes. Both NUnit and fit can be integrated into your build script. We
currently use NAnt to manage the source code checkout/update, build, build
installer, run unit tests, run fit tests.

Yes, we do the same with NUnit tests. I was asking whether the
VS.NET-integrated testing William described could be script-driven as well.
One hopes so, though I sometimes wonder whether Microsoft understands
non-GUI-based development.
 
The development of open source software can be mysterious. If you NEED a
feature added to a tool, and you can't wait for the original developers to
respond to your requests for help, you may be tempted to copy code down,
change it yourself, and post the change back up as a different project.

It isn't completely clear which came first. Doesn't really matter. Nunit
is more widely used, I think. More folks integrate with it. For Visual
Studio Widbey, there will be an easy conversion from Nunit... not so easy
from Cppunit or Csunit... so if you have the choice, go with Nunit.

Nunit is for developers to write and refactor code, not for testers to
automate every possible test. Testers need things like multithreaded
support, remote invocation of the test and collecting the result, etc.
Things that developers don't need. There are testing frameworks for
automation that are better than NUnit. But for doing test-driven
development, and Build Verification Testing (a.k.a sniff testing), Nunit is
very good.

-- Nick
 
How do you get VS to attach to NUnit ???? - i haven't figured that out yet

Regards
Arne Rasmussen
 
Back
Top