Visitar URL original
Confusing inconsistency in example method calls in “stubbing and verifying is redundant” note of “when” and “verify” Javadoc · Issue #3837 · mockito/mockito · GitHub
Skip to content

Confusing inconsistency in example method calls in “stubbing and verifying is redundant” note of “when” and “verify” Javadoc #3837

Closed

Description

@mminot-yseop

Currently using Mockito 5.23.0.

The Javadoc of when and of verify say:

Although it is possible to verify a stubbed invocation, usually it's just redundant. Let's say you've stubbed foo.bar(). If your code cares what foo.bar() returns then something else breaks(often before even verify() gets executed). If your code doesn't care what get(0) returns then it should not be stubbed.

I love this explanation and often want to show it to colleagues, but we then get really confused about why the example suddenly switches from foo.bar() to get(0) toward the end. This kinda defeats the purpose of me showing that stuff to others.

Maybe it’s intentional, but then I don’t get it. 🤔 It looks like a remnant from an older version of that documentation, to me (I also know that in some old versions of Mockito there used to be a suspicious link there – a colleague of mine ended up on a shady online casino website because of this 🤔 if my memories are correct).

Sidenote: There should be a space in “breaks(often” before the parenthesis.

Activity

  1. raphw commented on Jun 23, 2026

    @raphw
    Member

    Good point. Could you adjust this and send us a PR?

  2. added a commit that references this issue on Jun 25, 2026
    f1283b0
  3. mminot-yseop commented on Jun 25, 2026

    @mminot-yseop
    ContributorAuthor

    Good point. Could you adjust this and send us a PR?

    Thanks for your attention.
    Done. Hopefully it’s ok.
    #3838

  4. added a commit that references this issue on Jun 26, 2026
    f3cf74c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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