I am trying to learn assertThrows
in junit5
, it takes Executable
as 2nd arg which has a void execute()
method. But while going through the example on the same in the below example we are passing it a LAMBDA
which returns a double with method double divide(int a , int b)
. Now how is it possible to pass the below lambda if it does not have the same signature as the execute
method of the Excecutable
. It should give compile error
right?
assertThrows(ArithmeticException.class,() -> m.divide(1, 0),"Failed");