You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
In your UserServiceSpec test class you inject mock[UserRepository] by overriding userRepository in components.Default as "override val userRepository = mock[UserRepository]". Then you call, for example, "users.getById(anyLong)" which in turn will use mocked userRepository.
I was wondering if there is a way to not to call "users.getById(anyLong)" directly, but do the calls the same way you did in UserRouteSpec or LandingRouteSpec using WitApp approach and "route(header).get" calls and still being able to inject the mock implementation of the components.
Thank you.
The text was updated successfully, but these errors were encountered:
I missed this issue / question before. In order to mock the service and database layers and essentially unit testing the controller this would require the controller layer to do depend on some setting in application.conf. Now that I've done some refactoring to the project this should actually be pretty easy.
Hello,
In your UserServiceSpec test class you inject mock[UserRepository] by overriding userRepository in components.Default as "override val userRepository = mock[UserRepository]". Then you call, for example, "users.getById(anyLong)" which in turn will use mocked userRepository.
I was wondering if there is a way to not to call "users.getById(anyLong)" directly, but do the calls the same way you did in UserRouteSpec or LandingRouteSpec using WitApp approach and "route(header).get" calls and still being able to inject the mock implementation of the components.
Thank you.
The text was updated successfully, but these errors were encountered: