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

Chapter 2. Writing Well-structured Tests

In this chapter, we're going to learn how to write unit tests with a clean and consistent structure by means of the four-phase pattern, and outline why it is important to do so. We'll be explaining the purpose of a fixture, and how to get a clear definition of the relation between a component's behavior and its verification. Furthermore, we're going to gain insight on what to test, where to start, how to continue, and how to know when we are done. We'll be concluding with a discussion on the pros and cons of various testing naming conventions. In a nutshell, we will be going through the following topics:

  • The four phases of a unit test

  • Choosing the next functionality to test

  • Getting the test names right