且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

此处检测到错位的参数匹配器.您不能在 Mockito 中的验证或存根之外使用参数匹配器

更新时间:2023-08-29 18:35:04

你在调用测试方法时使用mockito anyString(),它应该只用于验证mock对象以确保使用测试中的任何字符串参数调用某个方法,但不调用测试本身.对于您的测试,请使用空字符串 "" 而不是 anyString().

You are using mockito anyString() while calling the test method, it should be used only for verifying a mock object to ensure a certain method is called with any string parameter inside the test, but not to invoke the test itself. For your test use empty string "" instead to anyString().