私はテストされたクラスの部分スタブのアプローチに行くことにしたかなり複雑なテストをしています。私のテストでは、私は次のようなものを持っています:scalaでスパイするオブジェクトのスタブに関する問題
val srv = new Service()
val srvSpy = spy(srv)
doReturn(now).when(srvSpy).getRunDateInTimeZone(futureChecklist)
doReturn("boo").when(srvSpy).interpolateChecklistName("name", now)
val returnTuple = (createdChlRev, createdChl)
doReturn(returnTuple).when(srvSpy).create(fChlCreatorId,
fChlCreatorEmail,
"username",
true,
templateId,
"boo",
optDueDate)(connection)
val (chlRev, chl) = srv.createFromFutureChecklist(futureChecklist)(connection)
上記のコードでは、最初の2つのスタブ付きメソッドが期待通りに機能しています。しかし、最後の1でエラーが発生します:
[error] Tuple2 cannot be returned by create$default$8() [error]
create$default$8() should return JsObject [error] *** [error] If you're unsure why you're getting above error read on. [error] Due to the nature of the syntax above problem might occur because: [error] 1. This exception might occur in wrongly written multi-threaded tests. [error] Please refer to Mockito FAQ on limitations of concurrency testing. [error] 2. A spy is stubbed using when(spy.foo()).then() syntax. It is safer to stub spies - [error]
- with doReturn|Throw() family of methods. More in javadocs for Mockito.spy() method.
私はスタブとまだ同じエラーを取得する近づい異なるの束をしようとしてきました。この時点ではどこを見てもわかりません。 私は何が間違っていますか?
アドバイスが役に立ちます。
ありがとうございました