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

RETURNS_DEEP_STUBS override a mock's toString to null #1898

Closed
strulovich opened this issue Apr 1, 2020 · 0 comments · Fixed by #1942
Closed

RETURNS_DEEP_STUBS override a mock's toString to null #1898

strulovich opened this issue Apr 1, 2020 · 0 comments · Fixed by #1942

Comments

@strulovich
Copy link

strulovich commented Apr 1, 2020

This example describes the issue:

  @Test
  public void mocksWithDeepStubsReturnNameOnToString() {
    Object proudMock = Mockito.mock(
        Object.class,
        Mockito.withSettings()
            .name("I'm a mock!")
            .defaultAnswer(Mockito.RETURNS_DEEP_STUBS));

    // fails, toString() returns null
    assertThat(proudMock.toString()).isEqualTo("I'm a mock!");
  }

I'm experiencing this on 2.26.0, (looking at ReturnsDeepStubs looks like it hasn't changed much since then).

I think toString should still return the mock's name, right now it returns a null.

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

Successfully merging a pull request may close this issue.

2 participants