0

I try to test exception thrown by a method like this:

Assertions.assertThatThrownBy( () ->  myMethod(paramA, paramB))
      .isInstanceOf(IllegalArgumentException.class).hasMessage(error);

However the problem is I still need to make more assertions on the return value of myMethod() without having to invoke it again separately. Since it is a lambda, I cannot assign the return value to external variable without a compile error.

How do I capture and make assertions on the return value of myMethod() without having to make another call?

Stefan Birkner
  • 24,059
  • 12
  • 57
  • 72
Ace
  • 1,501
  • 4
  • 30
  • 49

0 Answers0