java - How should I fill Map in abstract mock class? -


i don't know how fill map in abstract class(mocked). have architecture:

abstract class has member map:

abstract class parent{      protected map<integer, example> map;      protected abstract void methodforchild();      protected object dosomthingstaff(){       object o = map.get(...);       //...    } } 

right testing child class, , have mock parent class call methods. how can fill , work map @ parent mocked class ?

i have setter map. when doing next example:

map<string, example> mapexample = new hashmap<>(); mapexample.put(putdatahere); parent mockparent = mockito.mock(parent.class); mockparent.setmap(mapexample); 

map not filled while testing.

should 100% use mockito.calls_real_methods or there exists proper way resolve problem?

right testing child class, , have mock parent class call methods

i wouldn't expect mock parent class whilst testing child class (not sure how can that, frankly) expect mock class being used component of class under test.

note this:

parent mockparent = mockito.mock(parent.class); mockparent.setmap(mapexample); 

won't anything, since you're calling setmap() on mock, , won't execute anything. suspect that's issue.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -