Reputation: 57
I have a method yet to be defined, but the return type is known. Is there a way I can still mock this method and test the return to match with the return type?
def getX(a: String): Future[returnType]
when(someService.getX(a)).thenReturn(Future.successful(returnType))
Upvotes: 2
Views: 82
Reputation: 22635
If I understand you correctly, you're looking for ???.
You can define your method like:
def getX(a: String): Future[returnType] = ???
Then you could reference it in your tests or other code and everything would compile, but calling it will fail at runtime with NotImplementedError
thrown. It will also fail in tests unless you override it in mock.
Upvotes: 2