This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Test Results 4 failed tests JUnit

 
Tom Mordon
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been stuck on these test failures and have narrowed it down to the Order.calHandlingCharge() method. When I run and compile the program it works but I have these last 4 of 21 tests that fail in JUnit. Any thoughts? The error given is "caused an ERROR: java.lang.NullPointerException"



Any thoughts on what I can do to get it to pass the tests? I think that its not creating and instance of something that it needs for testing?

Pasted below: OrderTest.java, Order.java, ProcessOrder.java, OrderDriver.java


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33696
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. hChargeQuantity is null. I found this out by running the code and looking at the stack trace of the failure. Try tracking the code that calls setHChargeQuantity() to see why this is the case.
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where in your code do the fields defined on lines 289 and 290 get assigned valid references to arrays? By default, these will be set to null when an object is instantiated.
 
Tom Mordon
Ranch Hand
Posts: 30
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point they do not get created/instantiated or assigned a value by anything. I thought this was ok because I'm only comparing them to another null value, but maybe they are not a null value. I will assign them a value and compare to that value.

 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic