How can I test exception in completable future?
问题 I have been converting some code to be asynchronous. The original unit test used the annotation @Test(expected = MyExcpetion.class) but I don't think this will work because the exception I want to assert on is wrapped in java.util.concurrent.ExcutionException . I did try calling my future like this but my assertion is still failing and I don't love that I had to add in return null myApiCall.get(123).exceptionally((ex) -> { assertEquals(ex.getCause(),MyCustomException.class) return null } I