Setting Default Behavior of a Faked Class |
Top Previous Next |
When faking a class, you can set the default behavior of all methods. Then you can set a different behavior for a specific method.
MyClass* fakeMyClass = FAKE<MyClass>(FakeOption::<option>);
Example use of the HandleExceptionInTest flag with a Private method:
TEST_F(WhenToUse, HandleExceptionInTest) { // create a fake under test that will call all original code but exceptions will be caught in this test auto underTest = Fake<UnderTest>(FakeOptions::CallOriginal | FakeOptions::HandleExceptionInTest);
try { ISOLATOR_INVOKE_FUNCTION(_, &underTest, PrivateMethodThatWillThrow); ASSERT_EQ(TRUE, FALSE); // fail test we expected an excpetion } catch (MyException& e) { // can verify exception if needed } } |
Copyright Typemock Ltd. 2009-2025. All Rights Reserved.