title: GMock: Overriding a default expectation
body: <p>In GMock, is it possible to replace a previously set expectation?</p>
  
  <p>Assume, a test suite has a default expectation for a specific method call, which is what most test cases want:</p>
  
  <pre><code>class MyClass {
  public:
      virtual int foo() = 0;
  };
  
  class MyMock {
  public:
      MOCK_METHOD0(foo, int());
  };
  
  class MyTest: public Test {
  protected:
      void SetUp() {
          EXPECT_CALL(m_mock, foo()).WillOnce(Return(1));
      }
      MyMock m_mock;
  };
  
  TEST_F(MyTest, myTestCaseA) {
      EXPECT_EQ(1, m_mock.foo());
  }
  </code></pre>
  
  <p>This is working fine. Some of the test cases, however, have different expectations. If I add a new expectation, as shown below, it does not work.</p>
  
  <pre><code>TEST_F(MyTest, myTestCaseB) {
      EXPECT_CALL(m_mock, foo()).WillOnce(Return(2));
      EXPECT_EQ(2, m_mock.foo());
  };
  </code></pre>
  
  <p>I get this message:</p>
  
  <pre><code>[ RUN      ] MyTest.myTestCaseB
  /home/.../MyTest.cpp:94: Failure
  Actual function call count doesn't match EXPECT_CALL(m_mock, foo())...
           Expected: to be called once
             Actual: never called - unsatisfied and active
  [  FAILED  ] MyTest.myTestCaseB (0 ms)
  </code></pre>
  
  <p>I understand why I am getting this. The question is how to cancel the default expectation, if a test case specifies its own? Does GMock allow it or what approaches can I use to achieve the intended behaviour?</p>