我对apachecrunch非常陌生。这是我写的第一个测试用例。目前我正在为dofn编写测试用例,但它说的是nullpointerexception。
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import org.apache.crunch.Emitter;
import org.apache.crunch.Pair;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class OutputResultTest {
@Mock
InMemoryEmitter <String> emitter = new InMemoryEmitter<>();
@Test
public void TestProcess(){
OutputResult outputResult = new OutputResult();
//String expected = "Thor Odinson scored 97.8";
Pair<String,Double> input = Pair.of("Thor Odinson",97.8);
outputResult.process(input,emitter);
assertEquals(expected,emitter.getOutput());
//verify(emitter).emit("Thor Odinson scored 97.8");//this works
//verifyNoMoreInteractions(emitter);//this works
}
}
暂无答案!
目前还没有任何答案,快来回答吧!