Misplaced argument matcher detected here. You cannot use argument matchers outside of verification or stubbing in Mockito

前端 未结 3 1866
感动是毒
感动是毒 2021-01-01 09:27

Out of the following two test cases in BundleProcessorTest.java, i am getting below exception, although, my first test case passes successfully.

3条回答
  •  误落风尘
    2021-01-01 10:29

    Ideally anyString() should not be used outside the mock or verify block.I was facing the same issue.Changing the anyString() to some string ("xyz") value works fine.

    Note : Make a note that you might use anyString() to some other methods that leads in failure of some other method. It wasted my one hour to figure it out. My actual test method was getting passes individually but when i was trying to run that in a hole it was getting failed because of the reason that some other test case was using anyString() outside to mock or verify block.

提交回复
热议问题