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

Working with advanced concepts


JUnit comes with a set of readymade rules, taking away some of the burden of common test-related development tasks, and we've already encountered a few of them. But the tool offers additional capabilities, allowing us to apply and combine rules in a way so as to meet special requirements, at which we'll have a look in the following section.

Using ClassRules

At times, integration tests need access to external resources, which can be expensive to establish. If these resources do not contribute more to the precondition of any test, rather than being an environmental invariant, testing individual creations and disposing of them might be a waste.

Think of an application server necessary as the infrastructure to provide the REST services you intend to validate. The application server does not contribute any test-specific state. It simply has to be there to be able to deploy, test, and undeploy REST resources on the fly. Because of this, it would be desirable to perform...