EasyMock と EasyMock CE 3.0 を使用して依存レイヤーをモックし、クラスをテストしています。以下は、解決策を見つけることができないシナリオです
テストするクラスがあります。これは、入力パラメーターを受け取り、同じ param を変更する依存クラスの void メソッドを呼び出します。私がテストしているメソッドは、変更されたパラメーターに基づいていくつかの操作を実行しています。これは、さまざまなシナリオで今テストする必要があります
同じシナリオを入れようとした以下のサンプルを考えてみましょう
public boolean voidCalling(){
boolean status = false;
SampleMainBean mainBean = new SampleMainBean();
dependentMain.voidCalled(mainBean);
if(mainBean.getName() != null){
status = true;
}else{
status = false;
}
return status;
}
そしてdependentMainクラスは以下のメソッド
public void voidCalled(SampleMainBean mainBean){
mainBean.setName("Sathiesh");
}
完全なカバレッジを得るには、true と false が返される両方のシナリオをテストする 2 つのテスト ケースが必要ですが、void メソッドの動作を設定してこの入力 Bean を変更することができないため、常に false になります。EasyMock を使用して、このシナリオの結果として true を取得するにはどうすればよいですか
助けてくれてありがとう。