From leavens@larch.cs.iastate.edu Sun Nov 14 13:20:47 2004 Date: Sun, 14 Nov 2004 13:20:47 -0600 (CST) From: Gary T. Leavens To: William Gerald Hoffa Subject: Re: Updates to syllabus in 362, exercise for Monday (#13) Hi Bill, On Sun, 14 Nov 2004, William Gerald Hoffa wrote: > I was wondering when homework 8 problem 4 part c was due? I thought in class > that you said everything but the code would be due before thanksgiving break, > and after part d (the code) would be due. Maybe I'm just mistaken, but I don't > see part c ever being due on the syllabus right now. Ach, you're right, I didn't get homework 8 problem 4 properly on the syllabus. What you said was what we had agreed to and what the homework 8 problem file said (and still says). I have now fixed the syllabus. Thanks for the correction. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ------------------------------ From leavens@larch.cs.iastate.edu Tue Nov 16 02:27:08 2004 Date: Tue, 16 Nov 2004 02:27:08 -0600 (CST) From: Gary T. Leavens To: Michael Roberts Cc: cs362s@cs.iastate.edu Subject: Re: ex 14 Hi Michael, On Tue, 16 Nov 2004, Michael Roberts wrote: > I think there is a minor error in exercise 14. The directory listed in the > paragraph is correct, but in the command to copy the file it is listed as > being in the homework directory, but it's really in exercises. It's not a > big deal, but caused me some momentary confusion. Thanks! I have fixed that now. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ------------------------ From leavens@larch.cs.iastate.edu Tue Nov 16 17:35:07 2004 Date: Tue, 16 Nov 2004 17:35:07 -0600 (CST) From: Gary T. Leavens To: Robert Dyer Cc: Staff for Com S 362 -- Kun Liang , Matthew Ring Subject: Re: CS362 Ex14 question Hi Robert, On Tue, 16 Nov 2004, Robert Dyer wrote: > I was wondering how exactly we go about showing the output of our > tests. I am running the tests in Eclipse and it shows the output in > that frame window real well but I'm not sure how else to show this. Thanks for pointing this out. I'll look into how to print from Eclipse. But you can have junit give text output (to a console window) and save it to a file with the following Unix shell command java HistoricalDataTest > HistoricalDataTest.out This also should work on Windows or a Mac. It does require that the junit.jar file be in your CLASSPATH, however. > Also, would is be correct for me to assume that the size() method > will actually pass since the constructor incorrectly sets count to > -1 and size returns count + 1 (thereby offsetting that error)? Yes, sorry about that. You can change one of these so that they are not offsetting (e.g., initialize to -2). Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------- From leavens@larch.cs.iastate.edu Tue Nov 16 22:38:54 2004 Date: Tue, 16 Nov 2004 22:38:54 -0600 (CST) From: Gary T. Leavens To: Matt Hall Cc: Staff for Com S 362 -- Kun Liang , Matthew Ring Subject: Re: ex14 Hi Matt, On Tue, 16 Nov 2004, Matt Hall wrote: > I am un-sure how to go about exercise 14. Why is the constructor private? Here > is how i would want to do my testSize() method: > > public void testSize() { > HistoricalData hd = new HistoricalData(0.0,0.0,1); > Assert.assertEquals(1,hd.size()); > } > But this is not possible since the constructor is private. What i am > overlooking? Thanks, The constructor at the top of the file, which is public. Once you create it with no arguments, you have to use add to add measurements. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ----------------------- From leavens@larch.cs.iastate.edu Tue Nov 16 22:25:16 2004 Date: Tue, 16 Nov 2004 22:25:16 -0600 (CST) From: Gary T. Leavens To: Ted Skjei Cc: Com S 362 students and staff -- Aaron Becker , com_s_362@cs.iastate.edu, Staff for Com S 362 -- Kun Liang , Matthew Ring , Dan Hrivnak , Jacob Huber , Josh Solyntjes , Gary Leavens , Matt Hall , William Gerald Hoffa Subject: Re: ex14 question - how to print output of JUnit tests Hi Ted, On Tue, 16 Nov 2004, Ted Skjei wrote: > How do I print out the JUnit tests? (I just added the following to the ex 14 file; sorry for not having all of this information earlier.) You can get output from the JUnit tests from within Eclipse by running the HistoricalDataTest as a Java application instead of as a JUnit test, and copying the output from the Eclipse console window. Or you can do this outside of Eclipse, in the Unix shell, by using the command line (at the Unix prompt): $ java HistoricalDataTest > HistoricalDataTest.out This also should work on Windows (in a console) or a Mac. All of these require that the junit.jar file be in your CLASSPATH (the Java Build Path in Eclipse). Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@larch.cs.iastate.edu Tue Nov 16 23:38:59 2004 Date: Tue, 16 Nov 2004 23:38:59 -0600 (CST) From: Gary T. Leavens To: Matt Hall Cc: Staff for Com S 362 -- Kun Liang , Matthew Ring Subject: Re: ex14 Hi Matt, On Tue, 16 Nov 2004, Matt Hall wrote: > Can i write get methods in the HistoricaData class? I am runing into the > problem of not being able to access sum, max and count. I would like to say > getSum() and have it return it so i can check with Assert.assertEquals(). Is > there a better way to do this? Thanks, > Matt Hall You shouldn't rely on the class you are testing to keep track of the sum, max and count correctly (and of course this one doesn't!). So instead of trying to access them from HistoricalData, keep track of what these values should be, in your testing code. Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------- From leavens@larch.cs.iastate.edu Thu Nov 18 00:56:05 2004 Date: Thu, 18 Nov 2004 00:56:05 -0600 (CST) From: Gary T. Leavens To: Drew Templeton Subject: Re: Exercise 14 Hi Drew, On Thu, 18 Nov 2004, Drew Templeton wrote: > Hello Prof. Leavens. I'm still having some touble with my JUnit testing. I can't > figure out how i'm supposed to test for the current values of the variables in > the HistoricalData class without having them be public or having any correct get > methods. I see there are the methods such as size() where i could find out the > value, but they are incorrect so can i still use them? I have the testing > working out correctly with the variables public, so i just have to figure out > how to find the values and it should be ok. Thanks for the help! You shouldn't rely on the class you are testing to keep track of the sum, max and count correctly (and of course this one doesn't!). So instead of trying to access them from HistoricalData, keep track of what these values should be, in your testing code. You can of course call the incorrect methods, but you can't trust them... Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580