To unit test the method doSomething(String name) in ClassA below, what things should I test on the return value?
My first thought is to test
- that the name attribute is set properly on Wrapper
- that the formattedName attribute on Wrapper is properly formatted
But on second thought, should I instead test the value of formattedName in the unit test for UtilClass.format(String name)? Or should I do it in both places?
public class ClassA {
public Wrapper doSomething(String name) {
Wrapper wrapper = new Wrapper();
wrapper.setName(name);
wrapper.setFormattedName(UtilClass.format(name));
return wrapper;
}
}