mockito

mock case class in scala : Mockito

天涯浪子 提交于 2020-08-26 03:40:22
问题 In my play application i intend to mock a case class. I am able to do so but it creates an object with all member variables null. Is there a way to create mock objects of a case classes such that the object can have some members initialized? case class User(name: String, address: String) val mockUser = mock[User] user.name // null user.address //null how do i create a mockUser such that i can assign some values to name and address? Edit: I need the ability to mock the object because i want to

mock case class in scala : Mockito

£可爱£侵袭症+ 提交于 2020-08-26 03:39:08
问题 In my play application i intend to mock a case class. I am able to do so but it creates an object with all member variables null. Is there a way to create mock objects of a case classes such that the object can have some members initialized? case class User(name: String, address: String) val mockUser = mock[User] user.name // null user.address //null how do i create a mockUser such that i can assign some values to name and address? Edit: I need the ability to mock the object because i want to