2

I am using a WebService callout, returning a string, and testing it; I am quite new to it. The problem is in the Mock class. When I am debugging it, the response element is created, the string is associated and the response_element is inserted correctly in this way:

tO.AOResponse_element a_element = new tO.AOResponse_element();    
a_element.AOResult = 'http://www.google.com/archive';
System.debug('MOCK Set response: '+ a_element.AOResult);
response.put('response__x', a_element);
System.debug('MOCK Set response: '+ a_element); 

But after this, the flows goes to the original class (not the mock) and when it returns from it, it gives an error attempting to de-reference a line object, and that line references to the original string to be returned in the non-mock class.

How can I solve it?

1 Answer 1

3

The problem is with this line:

response.put('response__x', a_element);

The correct key value is response_x, not response__x.

2
  • Many thanks. So if the program doesn't recognize that field, it goes in the original webservice class and fails, I guess.
    – Franktrt
    Commented Mar 14, 2017 at 15:22
  • @Franktrt Yes, if the response value doesn't match exactly, this would cause the problem.
    – sfdcfox
    Commented Mar 14, 2017 at 16:15

You must log in to answer this question.

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