Re: Determining if a test passed or failed

Michael Reppy <[email protected]> Mon, 28 Jul 2008 13:04:51 -0400
Newsgroups gmane.comp.windows.dotnet.nunit.user
Message-ID <[email protected]>
That's really a test coverage question, there are tools other than NUnit 
to do this automatically, but I personally don't know much about them, 
I've just read bits and pieces here & there.

What I've done is use reflection in a test to examine the class that the 
test fixture is supposed to cover.  Two issues that we like to cover are

a) are all public constants right?  It wouldn't do to have an accidental 
typo in an xml name tag.
b) are all public methods null/max/min safe?

Use reflection to look up all the things of interestand then iterate 
through the collection checking constants or firing off method calls 
with crazy values.

I've looked at using the same framework to examine if all methods are 
tested, but haven't done anything satisfactory.  It is quite easy to 
write a list of known methods that will automatically fail if a new 
method is added to the class under test, but the list of methods that 
are known to be tested has to be updated manually.

This is all done in one test method, and doesn't involve any of NUnit.


Hope this helps somewhat
-Mikey Reppy

> However, the programmers could add new methods to this class at any time.
> My test suite must be smart enough to know that a new method has been
> created and that a corresponding test does not yet exist (obviously it would
> not do to have a test suite that properly test class.A() and class.B(), and
> shows all green when there is a new class.C() that has never been called).
> It must also know when a test does exist but has not been executed or did
> execute and failed.  The suite will then notify the tester that not all
> methods in the class have been exercised and which ones have/have not been
> successful.
> 

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/