scalamock - How to mock a class with scala mock -


in doc of scalamock, said that:

mocking classes, traits , case classes

is 1 of feature supported.

i have following case class:

case class dspaceitemwrapper(private val item: item) 

when do:

val item = mock[dspaceitemwrapper] 

i following error:

error:(18, 24) not enough arguments constructor dspaceitemwrapper: (item: org.dspace.content.item)org.iadb.poolpartyconnector.dspaceutils.dspaceitemwrapper. unspecified value parameter item. val item = mock[dspaceitemwrapper] ^

i know implement interface it, in case, me better understand how mock case class/a class has constructor.

many thanks,

maatari

currently, cannot mock classes not have default constructor defined.

you can workaround creating subclass has default constructor defined , mocking subclass:

class mockabledspaceitemwrapper extends dspaceitemwrapper(null) val item = mock[mockabledspaceitemwrapper] 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -