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

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -