@Test(expected = RuntimeException.class) public void shouldRethrowExceptionIfNoLog() { ReflectionUtils.setField(instrumenter, "log", null); given(nodeProcessor.processNode(astNode)).willThrow(new RuntimeException("Ouch!")); instrumenter.visit(astNode); }
@Test(expected = RuntimeException.class) public void shouldRethrowExceptionWhileLoggin() { given(nodeProcessor.processNode(astNode)).willThrow(new RuntimeException("Ouch!")); given(astNode.getLineno()).willThrow(new IllegalArgumentException("Ouchy!")); instrumenter.visit(astNode); }
@Test public void shouldLogException() { RuntimeException exception = new RuntimeException("Ouch!"); given(nodeProcessor.processNode(astNode)).willThrow(exception); given(astNode.getLineno()).willReturn(7); instrumenter.visit(astNode); verify(logger).log(SEVERE, "Error on line 7 of /dir/file.js", exception); }