Hadoop unit test with mocked out Context

716 Views Asked by At

I am trying to write an unit test for a hadoop job. The catch is that the mapper uses the Context argument passed on to it in order to determine which file is being read by it at that moment. It makes the following call:

String inputFile = ((FileSplit) context.getInputSplit()).getPath().toString();

However, while writing a unit test for the mapper using MRUnit, I cant seem to find any way to mock out this Context object. Even MapDriver does not seem to have any option for setting a new Context object. Is there a way I can write a unit test for this mapper class?

1

There are 1 best solutions below