junit-team/junit — pull request #792 by rowanhill (2013-12-24 12:47:59+00:00)
Title: Allow expecting an exception's cause has a specific type

Hi,

Sorry for just jumping in with a pull request without discussing this first - I realise it might not get accepted, as a result! It was just so quick and easy I thought it'd be best to get a PR in and have it rejected if need be.

I recently had need to match on the type of an exception's cause, and was briefly confused by `ExpectedException#expect` taking either a `Matcher` or a `Class`, but `expectCause` only taking a `Matcher`. Obviously, what I wanted could be achieved via `expectedCause(instanceOf(...))` (as pointed out in #337), but my dev experience would have been marginally more pleasant if I hadn't had to work this out - perhaps it's worth reconsidering this choice? This PR brings parity to the two methods.

Note that if this is merged, we should probably do something similar with #778.

Thanks,
Rowan