好吧,这很奇怪。Mockito,Java,在 Windows 上。
when(mongoTemplate.findAndModify(any(Query.class), any(Update.class), any(FindAndModifyOptions.class), eq(Task.class)))
.thenReturn(t1)
.thenReturn(t2);
Run Code Online (Sandbox Code Playgroud)
现在,如果我在调试模式下运行它,它就可以正常工作。但是,如果我在时间上设置断点,并且单步执行,则会失败。
IntelliJ 中的错误是
org.mockito.exceptions.misusing.WrongTypeOfReturnValue:
Task cannot be returned by toString()
toString() should return String
***
If you're unsure why you're getting above error read on.
Due to the nature of the syntax above problem might occur because:
1. This exception *might* occur in wrongly written multi-threaded tests.
Please refer to Mockito FAQ on limitations of concurrency testing.
2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies …Run Code Online (Sandbox Code Playgroud)