@Override public List<Pair<K2, V2>> run() throws IOException { try { preRunChecks(myReducer); initDistributedCache(); MockReduceContextWrapper<K1, V1, K2, V2> wrapper = getContextWrapper(); mos = new MockMultipleOutputs(wrapper.getMockContext()); try { PowerMockito.whenNew(MultipleOutputs.class).withArguments(wrapper.getMockContext()).thenReturn(mos); } catch(Exception ex) { //Wrap the exception to avoid changing the method signature throw new IOException(ex); } myReducer.run(wrapper.getMockContext()); return wrapper.getOutputs(); } catch (final InterruptedException ie) { throw new IOException(ie); } finally { cleanupDistributedCache(); } }