Open
Description
- The mockito message in the stacktrace have useful information, but it didn't help
- The problematic code (if that's possible) is copied here;
Note that some configuration are impossible to mock via Mockito - Provide versions (mockito / jdk / os / any other relevant information)
- Provide a Short, Self Contained, Correct (Compilable), Example of the issue
(same as any question on stackoverflow.com) - Read the contributing guide
I am new to Mockito so this may be a simple issue but I couldn't find a solution
val users = List(User(name = "A"))
val userRepoMock = mock[UserRepo]
"GET /users" should {
"return the users" in {
when(userRepoMock.get()).thenReturn(Future.successful(Good(users)))
When I run the test, it fails as follows
value thenReturn is not a member of Nothing
[error] L55:
when(userRepoMock.get()).thenReturn(Future.successful(Good(users)))
[error] L55:
Here is the definition of UserRepo
trait UserRepo {
def get(): Future[List[User]]
}
object UserRepo {
class ActorImpl @Inject()(actor: UserSyncActor.Ref) extends UserRepo {
override def get(): Future[List[User]] = {
implicit val timeout: Timeout = 10.seconds
actor.ref.ask(UserSyncActor.GetUsers).mapTo[List[User]]
}
}
}
versions:
Mockito ( mockito-core: 3.3.3, mockito-scala_2.12 )
os ( MacOS )
Could anyone can help me to fix this issue, please?
Thanks in advance
Metadata
Metadata
Assignees
Labels
No labels