| Author |
Test Results 4 failed tests JUnit
|
Tom Mordon
Ranch Hand
Joined: Apr 26, 2012
Posts: 30
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26144
|
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4115
|
|
|
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.
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
Tom Mordon
Ranch Hand
Joined: Apr 26, 2012
Posts: 30
|
|
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.
|
 |
 |
|
|
subject: Test Results 4 failed tests JUnit
|
|
|