Invalid use of argument matchers

前端 未结 1 1608
迷失自我
迷失自我 2020-12-14 16:59

The simple test case below is failing with an exception.

org.mockito.exceptions.misusing.InvalidUseOfMatchersException:
Invalid use of argument matchers! 3 m         


        
相关标签:
1条回答
  • 2020-12-14 17:38

    Mockito requires you to either use only raw values or only matchers when stubbing a method call. The full exception (not posted by you here) surely explains everything.

    Simple change the line:

    when(jdbcTemplate.queryForObject(anyString(), any(SqlParameterSource.class), String.class
                            )).thenReturn("Test");
    

    to

    when(jdbcTemplate.queryForObject(anyString(), any(SqlParameterSource.class), eq(String.class)
                            )).thenReturn("Test");
    

    and it should work.

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