background preloader

Outils

Facebook Twitter

EasyMock. Mockito. 06-10-2012: Mockito 1.9.5 released!

Mockito

See the release notes. Should appear in maven central shortly. JMock. JMockit. Powermock. Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability.

Powermock

Often testability corresponds to good design, but this is not always the case. For example final classes and methods cannot be used, private methods sometimes need to be protected or unnecessarily moved to a collaborator, static methods should be avoided completely and so on simply because of the limitations of existing frameworks. PowerMock is a framework that extend other mock libraries such as EasyMock with more powerful capabilities. PowerMock uses a custom classloader and bytecode manipulation to enable mocking of static methods, constructors, final classes and methods, private methods, removal of static initializers and more.

By using a custom classloader no changes need to be done to the IDE or continuous integration servers which simplifies adoption.