From: Lane S. <la...@op...> - 2003-03-28 15:52:28
|
k, Just as an aside, I had a main() dependency too one time. I am determined to make you kick this habit now. Why do a test case? Because... a) a given fix might break something else which you have no knowledge and could not consider. This is the beauty of a big test suite like we now have. b) the test code is not in the baseline product with a confusing main() now in the API docs for the new WM reader to scratch his head about. c) the new test case improves the genetic code of WM: a new allele exists which should not be broken in the future by some mutant addition to the baseline or to a test case. d) you will sleep better knowing that if someone does break MathTool in the future, your compatriots will see that when they run ant test. e) it is easier to drop a method into an existing test case and then type 'ant test' than creating your own main() method one you have a test class that is one you are familiar with. All test cases subclass a base class Brian wrote which make it trivial to create a class like TestKeatsChanges.java. That would be fine with me :). The more tests the better. ant test is really magic once you get hooked. So, it is a matter of changing your test drug of choice :). ant {test-mySpecialThingie} is what I use to test a subset of existing tests. I am now writing test cases before I actually write a class :). -Lane kea...@na... wrote: > I guess I was just lazy. There aren't any existing tests for the > MathTool AFAICT. > > I don't know exactly how to do a test case for random() -- since we > obviously don't know what the expected result is. I suppose I could > loop a bunch of times and make sure that all values returned are in > range and that all values in the range get returned, or I could just > compute the min/max/mean and check them. But this seems like overkill > for such a simple (one-line) method. > > The main method I added allows you to do a quick visual check that the > thing is working. This is better than what we had before. > > Keats > > > -----Original Message----- > > From: Lane Sharman [mailto:la...@op...] > > Sent: Friday, March 28, 2003 10:22 AM > > To: Keats Kirsch > > Cc: web...@li...; jim...@ag...; > > EricB. Ridge > > Subject: Re: [Webmacro-devel] MathTool.random broken? > > > > > > Why did you not add a test case? > > > > -Lane > > > > Keats Kirsch wrote: > > > > > I've committed this change along with a little test in main(). > > > > > > Keats > > > > > > Eric B. Ridge wrote: > > > > > >> On Thursday, March 27, 2003, at 11:29 AM, > > kea...@na... > > >> wrote: > > >> > > >> > > I may fail to understand the code, but it seems wrong to me > > >> > > so I changed it to > > >> > > > > >> > > public static final int random(int start, int end) { > > >> > > int iRet = start + (int) ((end - start + > > >> > > 1)*java.lang.Math.random()); > > >> > > return iRet > end ? end : iRet; > > >> > > } > > >> > > > >> > Your code looks right to me, but the final test is > > unnecessary, since > > >> > Math.random() is always less than 1.0. > > >> > > > >> > Eric, I think this was your thing. Do you want to do the fix, or > > >> > shall I? > > >> > > >> If you're in the mood, go ahead. :) I'm snowed under here at the > > >> office. > > >> > > >> eric > > >> > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > > This SF.net email is sponsored by: > > > The Definitive IT and Networking Event. Be There! > > > NetWorld+Interop Las Vegas 2003 -- Register today! > > > http://ads.sourceforge.net/cgi-bin/redirect.pl?keyn0001en > > > _______________________________________________ > > > Webmacro-devel mailing list > > > Web...@li... > > > https://lists.sourceforge.net/lists/listinfo/webmacro-devel > > > > > > > -- > > Lane Sharman > > Learn About Conga, All Java GUI Builder: http://opendoors.com/conga > > Java Software Portal: http://opendoors.com > > > > > > > > > -- Lane Sharman Learn About Conga, All Java GUI Builder: http://opendoors.com/conga Java Software Portal: http://opendoors.com |