Is it possible to expect exception in constructor with catch-exception? Can't figure out the syntax. For methods I am writing
catchException(instance).method();
and then, for example
assert caughtException() instanceof IndexOutOfBoundsException;
What should I write for
new MyClass();
?
Using catch-exception library, recommended way is to use the builder pattern:
If you are using JUnit 4 for unit testing, you can use Expected Exceptions:
In older version of JUnit youd simply catch your exception: