Sometimes, we cannot unit test our code, as the special Java constructs hide the testing impediments (a LAN connection or database connection in a private method, final method, static method, or initialization block), such as private methods, final methods and classes, static methods and initialization blocks, new operator, and so on. We refactor code for testability (explained in the Designing for testability with Mockito section) and, sometimes, compromise a good design for the sole purpose of testability. For example, final classes and methods are avoided, private methods are converted to protected or default, or unnecessarily moved to a collaborator class, static methods are avoided completely, and so on. This is done simply because of the limitations of the existing frameworks. Also, these aren't just feature limitations; they are intentional choices. Mockito could do the things PowerMock does, but it doesn't because those are test smells and strong indications...

Mockito Essentials
By :

Mockito Essentials
By:
Overview of this book
Table of Contents (14 chapters)
Mockito Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Exploring Test Doubles
Socializing with Mockito
Accelerating Mockito
Behavior-driven Development with Mockito
Unit Testing the Legacy Code with Mockito
Developing SOA with Mockito
Unit Testing GWT Code with Mockito
Index
Customer Reviews