abelx / googletest

Automatically exported from code.google.com/p/googletest
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Throwing an exception as default breaks call count expectation #480

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Example:

----
class MyMock {
public:
  MOCK_METHOD0(func, void());
};

TEST(MyTest, testMock) {
  MyMock mock;
  ON_CALL(mock, func()).WillByDefault(Throw(std::logic_error("error")));
  EXPECT_CALL(mock, func()).Times(0);
  try {
    mock.func();
  } catch (std::logic_error &e) {
  }
}
----

The test is green and passes. I expect it to fail, because the mock function is 
called once but I expect it not to be..

I assume in the gmock implementation, the call counter is incremented after the 
function returns and throwing an exception jumps over this piece of code.

Original issue reported on code.google.com by heinzis...@gmail.com on 18 Nov 2014 at 10:43

GoogleCodeExporter commented 9 years ago
using gmock 1.7.0, gtest 1.7.0 on linux x64 (ubuntu 14.10)

Original comment by heinzis...@gmail.com on 18 Nov 2014 at 10:44

GoogleCodeExporter commented 9 years ago
Sorry guys, I hit the wrong issue tracker. I refiled at the googlemock issue 
tracker here: 
https://code.google.com/p/googlemock/issues/detail?id=171&thanks=171&ts=14164832
07

You can close this issue here.

Original comment by heinzis...@gmail.com on 20 Nov 2014 at 11:34

GoogleCodeExporter commented 9 years ago

Original comment by sbe...@google.com on 20 Nov 2014 at 3:33