Mocking functions inside activites

Hi,
Is there a common way to mock functions inside activities? for example I have a function that gets called from an activity that tries to access REST API. I want to mock it…
thanks