title: Custom ACTION as fixture member - google test
body: <p>I want to execute an action every time a mock function is called. I tried implementing this using ACTION_P. See the code below:</p>
  
  <pre><code>ACTION_P(CompleteRegistrationWithStatus, status)
  {
      arg1-&gt;registrationCompleted(status);
  }
  </code></pre>
  
  <p>And the expectation goes like:</p>
  
  <pre><code> EXPECT_CALL(*mockObj, register(_)).WillOnce(CompleteRegistrationWithStatus(success));
  </code></pre>
  
  <p>Problem is, I had to use the same expectation multiple times, just different <em>status</em>. So I needed to put the expectation inside a member function of the test fixture to avoid code redundancy. But the function cannot access the ACTION_P I defined since it is not a member of the fixture. </p>
  
  <p>I tried searching for ACTIONs that are fixture members, like that of MATCHERs, but to no avail.</p>
  
  <p>Any suggestions for a possible solution or alternative? Any form of help is much appreciated. TIA!</p>