私はあなたがsamllのデータセットでmap-reduceをテストしようとしていると思うので、その場合は次のことをお勧めします
Map-Reduceの単体テストはあなたの問題を解決します
file からの linput の 1 行について mapper/combiner/reducer をテストする場合、最善の方法は、それぞれに対して UnitTest を使用することです。
サンプル コード:-
Mocking Frame を Java で使用すると、IDE でこれらのテスト ケースを実行できます。
ここでは、Mockitoまたは MRunit を使用しましたが、これも Mockito(Java Mocking Framework) に依存しています。
public class BoxPlotMapperTest {
@Test
public void validOutputTextMapper() throws IOException, InterruptedException
{
Mapper mapper=new Mapper();//Your Mapper Object
Text line=new Text("single line from input-file"); // single line input from file
Mapper.Context context=Mockito.mock(Mapper.Context.class);
mapper.map(null, line, context);//(key=null,value=line,context)//key was not used in my code so its null
Mockito.verify(context).write(new Text("your expected key-output"), new Text("your expected value-output")); //
}
@Test
public void validOutputTextReducer() throws IOException, InterruptedException
{
Reducer reduer=new Reducer();
final List<Text> values=new ArrayList<Text>();
values.add(new Text("value1"));
values.add(new Text("value2"));
values.add(new Text("value3"));
values.add(new Text("value4"));
Iterable<Text> iterable=new Iterable<Text>() {
@Override
public Iterator<Text> iterator() {
// TODO Auto-generated method stub
return values.iterator();
}
};
Reducer.Context context=Mockito.mock(Reducer.Context.class);
reduer.reduce(new Text("key"),iterable, context);
Mockito.verify(context).write(new Text("your expected key-output"), new Text("your expected value-output"));
}
}