Allow naming expectations
Does the feature exist in the most recent commit? No
Why do we need this feature?
When a test has multiple EXPECT_CALLs on the same function, it becomes difficult to determine which expectation is unmet.
Allowing the naming of expectations allows for more helpful error messages to help pinpoint which expectation failed.
Describe the proposal
Allow the specifying of name in the EXPECT_CALL
EXPECT_CALL(my_func, Call(_)).Name("Expect my_func to be called");
which should produce the following error message on failure
Actual function call count doesn't match "Expect my_func to be called"
Expected: to be called at least once
Actual: never called - unsatisfied and active
Related: https://github.com/google/googletest/issues/3683
I just tried this and I see that line numbers are printed. Does that not allow you to figure out which expectation failed?
myfile.cc:54: Failure
Actual function call count doesn't match EXPECT_CALL(c, G())...
Expected: to be called once
Actual: never called - unsatisfied and active
Unfortunately, the line number becomes less useful if the expectations are set in a method that gets called in different places
This can be closed now that #4041 got merged, right?