Mockear métodos estáticos (y mas)
Nota: Recientemente se ha publicado una nueva entrada que trata este mismo tema con mas detalle e incluyendo fragmentos de código fuente (en español). A continuación el artículo tal y como se publicó en su día:
What happens when you don’t have dependency injection and you’re using a third party library that contains classes of a certain vintage that contains static methods? One way is to isolate those classes by writing a wrapper or adaptor around them and using this to provide isolation during testing; however, there’s also another way: using PowerMock. PowerMock is a mocking framework that extends other mocking frameworks to provide much needed additional functionality. To para-phase an old advert: “it refreshes the parts that other mocking frameworks fail to reach”.
Read full post: