For my application I have a function handler
like that:
class MyFoo {
private MyFoo2 myFoo2 = new MyFoo2();
public void handler(Object o) {
if (o.getName().equals("Name1")) {
myFoo2.doSomeStuff1(o);
} else if (o.getName().equals("Name2")) {
myFoo2.doSomeStuff2(o);
}
}
}
class MyFoo2{
List<Object> objectList=new ArrayList<>();
public void doSomeStuff1(Object o){
//prepare Object o I
objectList.add(o);
}
public void doSomeStuff2(Object o){
//prepare Object o II
objectList.add(o);
}
public getObjectList(){
return objectList;
}
}
Now I want to test my function handler
with JUnit. To test it, should i have to get the objectList
from my MyFoo2
and check the entry or is there another way to check a function like that?
What is here a good way for testing?
Are test like that unnecessary?