1

I have added a new method in a class and added test data in the test class . It was PASS when I Ran the test class in Sandbox.

However , when I'm trying to deploy in Prod through Change Set, It's giving me "Null pointer Exception " error .

System.NullPointerException: Attempt to de-reference a null object Stack Trace: Class.MyClass.MyNewMethod: line 516, column 1 Class.MyClassTest.MyTestMethod: line 73, column 1

MyNewMethod is the same method which I have written newly and trying to deploy.

Please suggest why such error.

2
  • 2
    If you don't share any code it will be hard for us to know why the code threw a null pointer exception Commented Apr 20, 2015 at 10:31
  • 1
    Please share your code. You need to put null checks through out the class. Commented Apr 20, 2015 at 11:05

1 Answer 1

1

Best guess is that you have a hard-coded ID in your test from the sandbox that will be different or non-existent in production.

You will need to remove all hard-coded IDs from the tests and make them org independant by setting up the required test data within the test.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .