google / google/googletest

[Bug]: ON_CALL and EXPECT_CALL cannot be used on the same mock method

Open
#4,352 5 comments 0 reactions 1 assignee Claimed by @derekmauro View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

ON_CALL and EXPECT_CALL cannot be used on the same mock method. I would expect that EXPECT_CALL takes precedence if it matches, and otherwise ON_CALL fills in as the default. But at very least, as shown in the repro below, I would expect this to be the case if the matchers for ON_CALL and EXPECT_CALL cover disjoint subsets of the possible input.

### Steps to reproduce the problem

https://godbolt.org/z/e6f31EM1E

### What version of GoogleTest are you using?

HEAD

### What operating system and version are you using?

Not sure, what Godbolt uses under the hood. I've also reproduced this on Linux. I doubt the OS is relevant here.

### What compiler and version are you using?

clang 16

### What build system are you using?

Godbolt invokes the compiler directly. But I've also reproduced this with bazel 6.1, but I also doubt that's relevant.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.