Getting custom attribute from an Exception thrown during testing
- by Amit Bhargava
I'm using JUnit4 to test my code.
Now, I'm aware that the following annotation allows me to expect an exception of a certain type
@Test(expected = NipException.class)
However, I have an 'errorCode' property in my exception class which I would also like to verify.
This is because the same exception is thrown at three places in the same method with different error codes.
How do I access 'errorCode' of the thrown exception?