java - Spock mock the parent class method -
i have method looks this
public class bookitemreader extends staxeventitemreader<book> { protected list<book> doread() { list<book> booklist= null; try { booklist = converttobookimport((book) super.doread()); } catch (exception ex) { //do nothign } return booklist; } }
for above method, trying write test mocking method super.doread()
staxeventitemreader<book> staxeventitemreader = spy(staxeventitemreader) staxeventitemreader.doread() >> new book()
but, control invoking super class method doread
. can guide me mock super
class method, can stop invoking super class method in test?
i tried this solution , mock referring child class method.
bookitemreader reader = mockito.spy(new bookitemreader ()) mockito.doreturn(new book()).when((staxeventitemreader) reader).doread()
Comments
Post a Comment