Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow naming expectations #3970

Closed
rcywongaa opened this issue Aug 3, 2022 · 3 comments
Closed

Allow naming expectations #3970

rcywongaa opened this issue Aug 3, 2022 · 3 comments

Comments

@rcywongaa
Copy link

rcywongaa commented Aug 3, 2022

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: #3683

@derekmauro
Copy link
Member

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

@rcywongaa
Copy link
Author

Unfortunately, the line number becomes less useful if the expectations are set in a method that gets called in different places

@ghost ghost mentioned this issue Oct 20, 2022
gaspardpetit pushed a commit to eidosmontreal/googletest that referenced this issue Feb 24, 2023
Signed-off-by: Denis Hananein <i@zloylos.me>
kunitoki pushed a commit to kunitoki/googletest that referenced this issue Nov 4, 2023
Signed-off-by: Denis Hananein <i@zloylos.me>
@tobbi
Copy link
Contributor

tobbi commented May 14, 2024

This can be closed now that #4041 got merged, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants