Book Image

Mastering Unit Testing Using Mockito and JUnit

By : Sujoy Acharya
Book Image

Mastering Unit Testing Using Mockito and JUnit

By: Sujoy Acharya

Overview of this book

Table of Contents (17 chapters)
Mastering Unit Testing Using Mockito and JUnit
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Automating JUnit tests


Chapter 2, Automating JUnit Tests, covered the importance of test automation, CI, and test automation with Gradle, Maven, and Ant. This section reiterates the benefits of test automation.

The following are the benefits of test automation:

  • Assumptions are continually verified. We refactor the code (change the internal structure of the code without affecting the output of the system) to improve code quality such as maintainability, readability, or extensibility. We can refactor the code with confidence if automated unit tests are running and providing feedback.

  • Side effects are detected immediately. This is useful for fragile, tightly coupled systems when a change in one module breaks another module.

  • Test automation saves time and there is no need of immediate regression testing. Suppose you are adding a scientific computation behavior to an existing calculator program and modifying the code. After every piece of change, you perform regression testing to verify the integrity...