• Post Reply Bookmark Topic Watch Topic
  • New Topic

java autoboxing / unboxing and Junit -- Solved  RSS feed

 
Michael (Mikey) Green
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having some difficulty in finding out why the JUnit test fails to work "properly" on my simple adding program:






I am not sure whether Java 5 (ver. 12) supports autounboxing completely over the new enhanced for loop. The strange thing is that manually passing the (failing) arguments without using JUnit tests seems to work correctly... I am using Eclipse (3.2.2), Junit (3.2.1 r321).

Anyone else having the same problem? Please let me know if you need additional info.

Thanks!
[ March 26, 2008: Message edited by: Michael (Mikey) Green ]
 
Michael (Mikey) Green
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found the mistake - it's a classic logical problem. My sum variable isn't being reset, and it was carrying the values from the previous calculations causing it to give wrong result! I had a wrong assumption, that every assert statement works with a unique instance of the class... Obviously that's not so...

However, I am amazed that the Test Driven Development (TDD) methodology actually did help me catch out this logical error! To all the newbies! use TDD it WILL make you a better programmer!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!