Closed darylteo closed 11 years ago
It should work. Test case?
Sorry, here you go.
@Test(expected = StringIndexOutOfBoundsException.class)
public void exceptionTest() {
vertx.runOnLoop(new SimpleHandler() {
@Override
protected void handle() {
"Hello World".charAt(50);
testComplete();
}
});
}
Ummm.. that's because the exception isn't being thrown from the exceptionTest method, it's being thrown from the handle() method. Completely different methods.
Fair enough. I'll leave this here just in case anyone peruses it.
Expected parameter does not work if the exception is triggered on a different tick of the event loop.
Perhaps a way to get around this is to have a VertxAssert.expected(Class<? extends Exception>) method, and then compare any thrown exceptions with the expected exception in handleError().
Daryl