NUnit and C#

  • Thread starter Thread starter Arne Rasmussen
  • Start date Start date
David said:
There's another way, that's perhaps simpler in some circumstances. If
the nunit-gui is running, simply go into Debug-Processes, select NUnit
and click "Attach".

That's simpler if done just once. If you make unit testing with NUnit part
of your development process, it's better to set up your IDE appropriately --
IMHO.

Cheers,
 
Joerg Jooss said:
That's simpler if done just once. If you make unit testing with NUnit part
of your development process, it's better to set up your IDE
appropriately --
IMHO.

Cheers,

Thank you for all your help everybody - however i still have a couple of
questions. The system i'm going to use NUnit within is a system allmost in
its final state - and noone tought of using Nunit in the planning state - so
now i'm faced with the problem that all of the calculations i have to test -
are realized in private methods in inherited or abstract clases - and NUnit
is VERY much NOT happy about testing these sorts of methods - is there any
....elegant way - to go about that ???

Regards
Arne Rasmussen
 
That's simpler if done just once. If you make unit testing with NUnit part
of your development process, it's better to set up your IDE appropriately --
IMHO.

I guess that's OK if you like the console nunit, but I *really* like the
green bar. It just sort of cheers me up every couple of minutes. So
the NUnit-Gui stays open all the time, and unit tests are just an
Alt-Tab,Alt-R away. This way also makes the unit tests run a bit
faster, since you don't have to start up nunit every time you run the
tests, and that's pretty convenient if you test a lot. Of course
there's downsides too, like the fact that you don't get results in the
output pane.
 
Arne said:
Thank you for all your help everybody - however i still have a couple of
questions. The system i'm going to use NUnit within is a system allmost in
its final state - and noone tought of using Nunit in the planning state - so
now i'm faced with the problem that all of the calculations i have to test -
are realized in private methods in inherited or abstract clases - and NUnit
is VERY much NOT happy about testing these sorts of methods - is there any
...elegant way - to go about that ???

Regards
Arne Rasmussen

Will the 'internal' access modifier work for you in your case?
 
Julie said:
[SNIP]
Thank you for all your help everybody - however i still have a couple of
questions. The system i'm going to use NUnit within is a system allmost in
its final state - and noone tought of using Nunit in the planning state - so
now i'm faced with the problem that all of the calculations i have to test -
are realized in private methods in inherited or abstract clases - and NUnit
is VERY much NOT happy about testing these sorts of methods - is there any
...elegant way - to go about that ???

Regards
Arne Rasmussen

Will the 'internal' access modifier work for you in your case?

Hello Julie
Im not quite sure what you mean by that

Regards
Arne
 
Arne said:
Julie said:
[SNIP]
Thank you for all your help everybody - however i still have a couple of
questions. The system i'm going to use NUnit within is a system allmost in
its final state - and noone tought of using Nunit in the planning state - so
now i'm faced with the problem that all of the calculations i have to test -
are realized in private methods in inherited or abstract clases - and NUnit
is VERY much NOT happy about testing these sorts of methods - is there any
...elegant way - to go about that ???

Regards
Arne Rasmussen

Will the 'internal' access modifier work for you in your case?

Hello Julie
Im not quite sure what you mean by that

Regards
Arne

Change the methods from 'private' to 'internal' -- then have the test fixture
in the same assembly as the classes that it it testing, and it will be able to
access those 'internal' methods.

Outside of the assembly, internal methods behave the same as 'private'.
 
Arne Rasmussen said:
Thank you for all your help everybody - however i still have a couple of
questions. The system i'm going to use NUnit within is a system allmost in
its final state - and noone tought of using Nunit in the planning state - so
now i'm faced with the problem that all of the calculations i have to test -
are realized in private methods in inherited or abstract clases - and NUnit
is VERY much NOT happy about testing these sorts of methods - is there any
...elegant way - to go about that ???

You have essentially two options to do what you want - unless you want to
change private methods to public, which is not a very good idea.

Like Julie suggested you could put the test fixture in the application
assembly and make the methods that are to be tested internal. This is not
very nice though as then you're polluting the application assembly with
extra code that has nothing to do with the actual functionality provided by
the assembly.

Another way would be to place the test fixtures in their own assemblies and
call the methods to be tested via reflection. This is admittably a bit more
coding and does not look very pretty, but this way you would avoid putting
extra code in the application assemblies.

Finally, some people believe that you should not be testing private methods
directly anyway. Instead, tests should exercise the public interface of
classes which would then end up testing private methods indirectly.

Regards,
Sami
 
Thank you for taking you time for answering me - i think i'll have a go on
both approaches an see what happens - might end up with a hybrid - anyways
the developers of the system are going to do some re-factoring on the
system - so maybe THIS time they can consider the issue with testing ;-)

Regards
Arne Rasmussen
 
Back
Top