How do I use Assert.Throws to assert the type of the exception?

How do I use Assert.Throws to assert the type of the exception and the actual message wording? Something like this: Assert.Throws<Exception>( ()=>user.MakeUserActive()).WithMessage(“Actual exception message”) The method I am testing throws multiple messages of the same type, with different messages, and I need a way to test that the correct message is thrown depending on the … Read more

How do I assert my exception message with JUnit Test annotation?

I have written a few JUnit tests with @Test annotation. If my test method throws a checked exception and if I want to assert the message along with the exception, is there a way to do so with JUnit @Test annotation? AFAIK, JUnit 4.7 doesn’t provide this feature but does any future versions provide it? … Read more