Skip to content
Advertisement

Junit Force to throw Exception on method call

I am trying to throw the exception whenever simpleJdbcCall.execute(namedParameters) called but I see it is not throwing the error, is there something i am missing here ?

Here is my class

JavaScript

here is my Junit Class

JavaScript

Advertisement

Answer

When writing spring-boot integration test you should inject the mock beans using @MockBean annotation

JavaScript

You can a follow some of the examples here for testing exceptions in junit4 or junit5

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement