Mockito reset injected fields in the course of a test?

299 views Asked by At

I suspect I may be told that I need to redesign my test or my app class or something... but who knows, maybe not?

I have a CUT I'm testing with an injected spy java.util.Properties field mockedProps, standing in for field Properties props ...

Supposing in the course of its activities (e.g. in a functional or E2E test rather than a super-simple unit test) the CUT sets the value of the field props to a newly created Properties object. This makes this new field no longer accessible from the test method.

It would be nice to be able to say "reinject" the current props field as mockedProps ... is there any way of doing this or some technique that addresses this sort of problem?

0

There are 0 answers