我不知道是什麼原因造成此問題,但會引發InvalidUseOfMatchersException。InvalidUseOfMatchersException:未使用任何原始值
This exception may occur if matchers are combined with raw values:
//incorrect:
someMethod(anyObject(), "raw String");
When using matchers, all arguments have to be provided by matchers.
For example:
//correct:
someMethod(anyObject(), eq("String by matcher"));
For more info see javadoc for Matchers class.
導致異常的代碼如下。
when(EventHandlingForFileUpload.onUploadEvent(any(CustomBatchFile.class))).thenReturn(SomeCustomEvents);
奇怪。也許你可以添加你打算在那裏測試的onUploadEvent()方法的簽名。以及從生產代碼實際調用該方法的行。 – GhostCat