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

Getting the test names right


Finding good names is one of the challenges of crafting software. You need to find them all the time and for everything: classes, methods, variables, just to name a few. Because of that, the last section of this chapter explains the particularities of naming tests and balances the pros and cons of common approaches and conventions.

Test prefix

What makes a name a good name? To quote Uncle Bob:

"Three things: Readability, readability, and readability!"

He defines this later on as clarity, simplicity, and density of expression, [MART09]. Though this sounds reasonable, it leaves us with the question of how to achieve these qualities when naming our tests.

Before the arrival of annotations in the Java language, it was necessary to distinguish tests from ordinary methods to be able to process them by the JUnit runtime. This is because the latter has to pick up each test separately, run it, and report the results. The technical solution was to prefix the name of public...