BaseParser { protected final void die(String message) throws ParserException { String line = toParse.split("\n")[currentLine]; throw new ParserException(message + " - " + line, currentLine + 1, currentPosition); } BaseParser(String toParse); final boolean available(); final void skipWhitespaces(); final void skipComments();  }
@Test(expected = ParserException.class) public void testDie() throws ParserException { new BaseParser("").die("Something went wrong"); }