Book Image

Testing with JUnit

By : Leonard Przybylski, Frank Appel
Book Image

Testing with JUnit

By: Leonard Przybylski, Frank Appel

Overview of this book

Table of Contents (16 chapters)
Testing with JUnit
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Increasing efficiency with mock frameworks


While hand-crafting test doubles is a skill each unit tester should be able to master, mock frameworks aim to ease stand-in component creation and configuration. Hence, they profess to make your daily testing work more efficient. But as opinions on these tools are divided, this section will clarify the pros and cons and give some examples of decent usage.

The promised land?

"If all you have is a hammer, everything looks like a nail."

There are a couple of frameworks available claiming to simplify the usage of stand-in components. Unfortunately, these libraries do not always do a good job when it comes to the precise test double terminology, [GOUL12], which we've learned in the previous sections. While JMock, [JMOCK], and EasyMock, [EASYMO], for example, basically generate mocks, Mockito, [MOCKIT], despite its name, is spy centric. Maybe that's why most people talk about mocking, regardless of what kind of double they are really using.

Nevertheless,...