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

Writing dataset tests


The last section of this chapter will cover one of the most important usage scenarios for runners. It'll explain the sense and purpose of tests that run against specific data records and presents the advantages and disadvantages of the available approaches.

Using parameterized tests

Given all this new and fancy knowledge about pluggable processors, it's about time to advance our TimelineTest. One of the main functionalities our component provides is the ability to fetch items page-wise. But there are quite a few preconditions that determine the behavior of item fetching. This leads to just as many tests, which barely differ in their structure. Instead of rewriting the same pattern over and over again, wouldn't it be nice to reuse a common test and simply provide behavior defining pre- and post-conditions as a set of data beans?

In fact, there is more than one canned solution based on runner extensions. Let's start with the built-in mechanism of JUnit, the Parameterized...