I heard that creating object with static methods is not good for unit-testing. For instance, we have the following hierarchy:
public abstract class Base{
public static Base createConcrete(){
return new Concrete();
}
public static Base createSuperConcrete(){
return new SuperConcrete();
}
}
public class Concrete extends Base { }
public class SuperConcrete extends Base { }
It's better use instance FactoryMethod instead. Why does using static
methods cause too much pain in unit tests? Couldn't someone give an example?
Aucun commentaire:
Enregistrer un commentaire