Skip to content

Can't attach extra information to EXPECT_CALL #2646

@MovEaxEsp

Description

@MovEaxEsp

All the standard gtest EXPECT and ASSERT macros support at least 2 ways (that I know of) for attaching arbitrary information to their output to provide context in case of failure (<< at the end, or ScopedTrace).

EXPECT_CALL, however, doesn't support either of these mechanisms. I haven't found any way of including any extra information in an EXPECT_CALL (or ON_CALL I suppose), which makes it impossible to debug EXPECT_CALLs in subroutines as described in https://github.com/google/googletest/blob/master/googletest/docs/advanced.md#using-assertions-in-sub-routines

I hacked something for myself quite easily here, for the interested: https://github.com/MovEaxEsp/googletest/commit/a32b47d7467110a7fa6a5064ca339381ffc7bcdc

Ideally, EXPECT_CALL would include any active ScopedTraces at the time it's invoked, and include them in any failure output, and/or support << streaming so you could do:

EXPECT_CALL(...).WillOnce(...).RetireOnSaturation() << "my extra info";

but both of these might involve some work.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions