title: Passing arbitrary arguments to invocked methods with Google C++ Mocking Framework (Google Mock) (V1.5)
body: <p>I have a mock method. When it is called, I'd like it to call another function before calling its normal behavior. Something like :</p>
  
  <pre><code>EXPECT_CALL(*my_obj, MockedMethod(_,_,_,_,_,_))
      .WillOnce(DoAll(
          Invoke(my_obj, &amp;SomeAdditionalMethodIWantToCall),
          Invoke(my_obj, &amp;DefaultBehavior),
          ));
  </code></pre>
  
  <p>The only problem is that <code>SomeAdditionalMethodIWantToCall</code> expects parameter that not at all related to the one provided to <code>MockedMethod</code>. I'd like to be able to give them but I am struggling with the syntax. I wish there was something like (in fake syntax) :</p>
  
  <pre><code>EXPECT_CALL(*my_obj, MockedMethod(_,_,_,_,_,_))
      .WillOnce(DoAll(
          Invoke(my_obj, &amp;SomeAdditionalMethodIWantToCall, arg1, arg2, arg3),
          Invoke(my_obj, &amp;DefaultBehavior),
          ));
  </code></pre>
  
  <p>I have looked for such a thing in the documentation without any success.</p>
  
  <p>In <a href="https://code.google.com/p/googlemock/wiki/V1_5_CheatSheet#Using_a_Function_or_a_Functor_as_an_Action" rel="noreferrer">Using a Function or a Functor as an Action</a>, we have :</p>
  
  <ul>
  <li><p><code>Invoke(f)</code>, <code>Invoke(object_pointer, &amp;class::method)</code>, <code>InvokeWithoutArgs(f)</code>, <code>InvokeWithoutArgs(object_pointer, &amp;class::method)</code> which will just forward (or not) the parameter provided to the mocked function when it is called.</p></li>
  <li><p><code>InvokeArgument&lt;N&gt;(arg1, arg2, ..., argk)</code> seems to be for calling one of the parameter.</p></li>
  </ul>
  
  <p>In <a href="https://code.google.com/p/googlemock/wiki/V1_5_CheatSheet#Composite_Actions" rel="noreferrer">Composite Actions</a></p>
  
  <ul>
  <li><code>WithArg&lt;N&gt;(a)</code> and <code>WithArgs&lt;N1, N2, ..., Nk&gt;(a)</code> seem to be to select which parameters from the original function get forwarded.</li>
  </ul>
  
  <p>I guess I am missing something quite obvious but I am a bit stuck here so any suggestion will help.</p>