Hello, I’m trying to make a unit test for a java s...
# server
a
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?)
s
Have you tried using the
@Throws
annotation? (if you are able to modify the method in question)
a
didn’t want to modify it since its on other lib
fixed it with that solution 👍
🐕 1