フロントエンドからの一連のアクションをシミュレートする統合テストを作成しています。私はこのように私の期待を設定しています:
context.checking(new Expectations() {{
States state = states("service");
allowing(service).getPendingTxn();
will(returnValue(null));
when(state.isNot("has-pending-txn"));
one(service).createPendingTxn();
will(returnValue(txnId));
then(state.is("has-pending-txn"));
allowing(service).getPendingTxn();
will(returnValue(transaction));
when(state.is("has-pending-txn"));
}});
次に、テスト対象のコードがこの順序で呼び出しを行います。
これは私にはうまくいきません。service.getPendingTxn()が、指定された値ではなく、jMocknullオブジェクトを返しているようです。期待の後にwill(...)とwhen(...)の両方を書くと、何か間違ったことをしていると思いますが、よくわかりません。
ここに欠けているものはありますか?