• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Test Results 4 failed tests JUnit

 
Tom Mordon
Ranch Hand
Posts: 30
  • 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: 34225
341
Eclipse IDE Java VI Editor
  • 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: 7465
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • 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
  • 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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic