Mockito 'Misplaced argument detected here' in Java

前端 未结 1 370
Happy的楠姐
Happy的楠姐 2021-01-03 14:50

So I have this Mockito unit test:

@Test
    public void createCard() {

    when(jwtServiceMock.getId(anyString())).thenReturn(validUserToken);
    when(prof         


        
1条回答
  •  春和景丽
    2021-01-03 15:11

    The culprit is this part:

    .thenReturn(any(Orientation.class))
    

    any() is supposed to be used in conjunction with When.

    Do something like this:

    @Mock
    private Orientation orientationMock;
    
    // ...
    
    .thenReturn(orientationMock);
    

    0 讨论(0)
提交回复
热议问题