Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ArgumentMatchers not working for Mockito.mockStatic #2497

@nicolasmafra

Description

@nicolasmafra

When I do a mockStatic with argument matchers like this:

var mockedRequestClass = Mockito.mockStatic(RequestClass.class);
mockedRequestClass.when(() -> RequestClass.sendRequest(mockedUrl, any(), any())).thenReturn(null);

Mockito throws the following exception:
org.mockito.exceptions.misusing.MissingMethodInvocationException: when() requires an argument which has to be 'a method call on a mock'.

How can I use argument matchers with Mockito.mockStatic? Shouldn't that be possible?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions