I would have the desire to make the field either protected or package-private , and then enter the layout in your test, for example:
final SomeField sf = mock(SomeField.class); someFilter.sf = sf;
Otherwise, you can provide a constructor for entering the layout:
... public SomeFilter() { this(new SomeField()); } public SomeFilter(SomeField sf) { this.sf = sf; } ...
Then in your test, you could pass the layout like this:
final SomeField sf = mock(SomeField.class); SomeFilter someFilter = new SomeFilter(sf);
source share