Believe it or not, in some legacy systems you can find solutions where the business logic is implemented inside an enum. What we will discuss here is how to mock and stub (you will learn about stubbing more in Chapter 4, Stubbing Behavior of Mocks) an enum using PowerMock (since it's impossible to do it in Mockito). The PowerMock library setup has been described in the previous recipe, so we'll skip it. I will, however, repeat that the best outcome of using the PowerMock library would be to use it as a means to refactor the code, and, at the end of the day, remove the PowerMock dependency from the system since it is no longer needed.
Mockito Cookbook
By :
Mockito Cookbook
By:
Overview of this book
Table of Contents (17 chapters)
Mockito Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Free Chapter
Getting Started with Mockito
Creating Mocks
Creating Spies and Partial Mocks
Stubbing Behavior of Mocks
Stubbing Behavior of Spies
Verifying Test Doubles
Verifying Behavior with Object Matchers
Refactoring with Mockito
Integration Testing with Mockito and DI Frameworks
Mocking Libraries Comparison
Index
Customer Reviews