Hey Michael,

you might fall in love with the green bar after using it for a while.
If you use eclipse or some other ide including junit it so easy and powerful.

You might find some help here as well:

http://www.onjava.com/pub/a/onjava/2004/02/04/juie.html
http://www.junit.org/news/article/index.htm

As hossman said very important is to test limit values of  your "unit".
You should also let your test fail at the right moment and catch the
exception to test it for illegal values or state.
Something like that does a good job if you expect an exc.


try{
unit.doIt();
fail("illegal state");
}catch(theexc e){}

Have a look at the class junit.framework.Assert, the static methods
are very helpful.

to keep the code clean, keep the bar green :)

Simon



On 8/4/06, Chris Hostetter <[EMAIL PROTECTED]> wrote:

: Oh boy, how embarrassing for me.  I have never used any unit tests...I
: know I know...don't freak out people :)  I pretty much just started
: really coding in Java.  So, is there anyone out there who has time to
: help me add these to the code?  I would appreciate it and, on the plus
: side, the code will be better tested for the community.

Writing unit tests is a lot easier then it sounds .. especially if you are
writting them as they are ment to be: test of small "units" of code.

take al ook at some of the existing Filter tests, they should give you a
good idea of how to write a test...

http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestISOLatin1AccentFilter.java?revision=347991&view=markup
http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestLengthFilter.java?view=markup
http://svn.apache.org/viewvc/lucene/java/trunk/src/test/org/apache/lucene/analysis/TestStopFilter.java?revision=382158&view=markup

..the ideal thing is to not only test the expected "good" cases, but
also any cases where you expect an error to be generated -- not exactly
common in a TokenFilter, but it would be a good idea for example to test
what your Filter does when given plain text (ie: not an email address)






-Hoss


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to