Skip to content

Change EXPECT_CALLS to ON_CALLS in tests where expectations are not being tested #90

@LittleHuba

Description

@LittleHuba

What

We have a lot of places in our tests where we use EXPECT_CALL and strict_mocks for code that is not being actively tested in a specific test case. We should instead use ON_CALLS for these calls (e.g. in test fixtures) and explicitly add the EXPECT_CALLS within each unit test for the calls that specific test is testing.

How

Tests should follow the given-expected-when-then pattern which is an adaptation of the given-when-then pattern for GTest. EXPECT_CALLS should only be placed in the sections "expected". We do explicitly not want EXPECT_CALLS in any other section.
Go over all our tests and fix this.

Search for StrictMock in our codebase and judge whether a StrictMock is really necessary.
StrictMocks shall only be used if it must be verified that no other calls than the ones with expectations set are done. Consider that you can also put a EXPECT_CALL(...).Times(0) if this is only required for specific APIs.

Note: Not all tests apply the above pattern. Please judge whether you can easily add this pattern.

Estimates for realization

  • Effort large (needs further breakdown)
  • No impact on users expected

Category

  • Affects Detailed Design

Requirements / Architecture

  • Requirements / Architecture are not affected by this change?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions