title: Record method calls in one session for replaying in future test sessions?
body: <p>I have a backend system which we use a third-party Java API to access from our own applications. I can access the system as a normal user along with other users, but I do not have godly powers over it.</p>
  
  <p>Hence to simplify testing I would like to run a real session and record the API calls, and persist them (preferably as editable code), so we can do dry test runs later with API calls just returning the corresponding response from the recording session - and this is the important part - without needing to talk to the above mentioned backend system.</p>
  
  <p>So if my application contains line on the form:</p>
  
  <pre><code> Object b = callBackend(a);
  </code></pre>
  
  <p>I would like the framework to first capture that <code>callBackend()</code> returned b given the argument a, and then when I do the dry run at any later time say "hey, given a this call should return b".  The values of a and b will be the same (if not, we will rerun the recording step).  </p>
  
  <p>I can override the class providing the API so all the method calls to capture will go through my code (i.e. byte code instrumentation to alter behavior of classes outside my control is not necessary).</p>
  
  <p>What framework should I look into to do this?</p>
  
  <hr>
  
  <p>EDIT:  Please note that bounty hunters should provide actual code demonstrating the behavior I look for. </p>