Question

Currently, I am using GMock without GTest ( specifically, I'm using it with mstest ). Is there any way to get a string of the failed expectations ?

IE:

EXPECT_CALL( mockObject, MethodWith3Params( 1, 2, 3 ) ).Times(1);

// Do does not call MethodWith3Params at all.
stuffDoer.Do( mockObject);

Assert::IsTrue( Mock::VerifyAndClearExpectations( &mockObject ), " "/*What can I do here to say what expectation/s failed ?*/ );

I assume GMock is storing these strings ( or at least raw data that can be used to deduce a message ) somewhere, since GTest is able to tell you when an expectation isn't met.

Was it helpful?

Solution

You will need to create a class that inherits from ::testing::EmptyTestEventListener and instantiate it within the test. Refer to the Google Test Advanced Guide:

https://github.com/google/googletest/blob/master/docs/advanced.md#extending-googletest-by-handling-test-events

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top