java - Mockito.spy not changing real object -


calling method on spy object somehow has no effect on real spied object:

public class aaa {     public int a;      public void seta(int aa) {         this.a = aa;     }      public int geta() {         return a;     } }   public class proof {     @test     public void wtf() {         aaa obj = new aaa();         aaa spy = mockito.spy(obj);          spy.seta(22);          assertthat(obj.geta(), equalto(22));     } } 

how can be? suppose proof test should pass.

as seen in mockito doc:

mockito does not delegate calls passed real instance, instead creates copy of it.

this means original object obj isn't modify happens in spied object spy.


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -