André Martins

07/05/2022, 10:55 AM
Hello, I’m trying to make a unit test for a java service which uses a client written in kotlin. The client may throw a checked exception but since there are no checked exceptions in kotlin when calling the method from java it doesn’t force me to wrap it into a try..catch. When I’m trying to mock the method with Mockito it says I cannot throw a checked exception
Checked exception is invalid for this method!
The only ways I would be able to make the test is either rewrite the client method in java and mark it with checked exception or wrap the call and rethrow a runtime exception right? (any other ideias?)


07/05/2022, 11:00 AM
Have you tried using the
annotation? (if you are able to modify the method in question)

André Martins

07/05/2022, 11:02 AM
didn’t want to modify it since its on other lib
fixed it with that solution 👍
:cool-doge: 1