Is it possible to mock out the response from an AP...
# testing
r
Is it possible to mock out the response from an API call? I have a legacy method that I want to refactor and it has an API call within the body of that method. What I'd like to do is mock out the response from that
cfhttp
call so I can test the subsequent processing of the data returned. I've mocked the component with
createMock()
and mocked the result with
$property()
but when I run my test the API is called, which of course fails, because I'm not giving it all the info it needs to run. Is this type of thing impossible to test unless I wrap the API call in its own method, so I can mock that out completely? I'm cool with that if it's the only solution, I just wanted to have some tests in place before I did any refactoring. Opinions welcomed.