私は以下のメソッドをmockitoを使ってテストしようとしています。 class.getUserWishList("[email protected]")
を実行するときにgetProfileItemFinder().retrieveEmailRecipient(email)
メソッド呼び出しをスキップしたかったので、Mockitoの内部メソッドをスキップ
私は以下のコードを試しましたが、コードを実行しようとする度にdoReturnでmockito例外が発生しています。私が間違っていることをお勧めしますか?
サンプルモック方法:
profileItemFinder = spy(new TestProfileItemFinder());
doReturn(profileItem).when(profileItemFinder.retrieveEmailRecipient(email));
オリジナルメソッド:
public List<Map<String, Object>> getUserWishList(String email) {
// JSONArray profileGiftList = new JSONArray();
---------------------------------------------
-----------------------------------------------
if (email != null) {
RepositoryItem profileItem = getProfileItemFinder().retrieveEmailRecipient(email);
if (profileItem != null) {
----------------------------------
--------------------------------
}
}
}
}
---------------------------
}
何が例外ですか? – Deca
profileItemがatgリポジトリ項目で問題が発生し、正しく初期化されませんでした。 –