The code is working. Just to make it in Production, I need to do proper unit test to make sure the code coverage is above 75%.
In the Controller Extension, I made a simple Page Reference to save the record and it uses
update object.relatedObject__r to save the related object. Later in the Unit Test, it returns the error saying
Attempt to de-reference a null object.
The update line is controlled by condition that when
object.relatedObject__c == null, the update line would never be reached.
Therefore, I am sure that the object.relatedObject__c is not null. Then, I thought maybe some fields in the relatedObject are null, which might cause this error. Then I put content in all the fields in the relatedObject. However, the system still returns the error
"Attempt to de-reference a null object".
How do I solve this problem? Is there a way to test on the "Update object.relatedObject__r" code?
Thanks a lot.