I have an outer class, Outer, and an inner class, Inner. For testing a public method, outerMethod(), in Outer I need to create an instance of an Inner, which will be stored in a list called inners. The inner class is a modified version of another class, Other.
To overview:
class Other{
public Other(){
//doesnt matter actual implementation
}
}
class Outer{
private List<Inner> inners = new ArrayList<Inner>();
public Outer(){}
public void outerMethod(){}
private class Inner{
public Inner(Other other){}
}
}
My question is should I create a method like the following just for testing purposes.
public void createInnerInstance(Other other)
{
Inner inner = new Inner(other);
inners.add(inner);
}
Is there any other workaround for this? Now I can make Inner public but Outer is the only class that really uses Inner.
Regards