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

Employing custom solutions


Given the variety of possible applications, it's no wonder that there are custom rule solutions for both routine and fancy demands. Because of this, the last section of the chapter will dwell on noteworthy third-party implementations for each area.

Working with system settings

A source of constant burden is environment-specific functionality and state handling. Most of it is made accessible via the java.lang.System class. Setting and resetting system properties, capturing system output and so on produces quite a bit of overhead of boilerplate code. Luckily, a third-party utility called System Rules, [SYSRUL], comes to the rescue. It encapsulates the redundancies and supplies several rules to accomplish the various tasks efficiently.

Let's have a quick look at some of the more common challenges and see how system rules will help. If you need to ensure that a particular system property is removed before test execution, you can use the ClearSystemProperty test helper...