Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Testing with JUnit

You're reading from   Testing with JUnit Master high quality software development driven by unit tests

Arrow left icon
Product type Paperback
Published in Aug 2015
Publisher
ISBN-13 9781782166603
Length 200 pages
Edition 1st Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Leonard Przybylski Leonard Przybylski
Author Profile Icon Leonard Przybylski
Leonard Przybylski
Frank Appel Frank Appel
Author Profile Icon Frank Appel
Frank Appel
Arrow right icon
View More author details
Toc

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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image