1

I have method to to test junit below

public Response submitData(String a, BigInteger b, HttpServletRequest request){
}

I have mockito junit method below

@Test
public void submitData_Success() throws Exception {
    when(inAbcExample.submitData(anyString(),eq(new BigInteger("12")),mockRequest)).thenReturn(response);
}

I'm getting invalid use of matcher exception. whether above lines are correct

Maciej Kowalski
  • 25,605
  • 12
  • 54
  • 63
Karthick
  • 123
  • 2
  • 4
  • 11

1 Answers1

0

This error is present when you try to pass some params using the anyXXX() mockito wrappers and yet some of you params are still passed normally (like themockRequest in your case). You should refactor to the following:

@Test
public void submitData_Success() throws Exception {
    when(inAbcExample.submitData(anyString()
           ,Mockito.eq(new BigInteger("12")),Mockito.eq(mockRequest))).thenReturn(response);
}
Maciej Kowalski
  • 25,605
  • 12
  • 54
  • 63