Chapter 19. JUnit on steroids

 

Make everything as simple as possible, but not simpler.

Albert Einstein

This chapter covers

  • Transparent mocks utilization
  • Out-of-the-box DbUnit integration
  • Extended assertion capabilities
  • Bypassing encapsulation through reflection

Throughout this final part of the book, we’ve analyzed tools focused on testing specific technologies, such as AJAX applications and database access. In this final chapter, we evaluate tools that don’t fit a particular niche but rather facilitate overall test development by providing helper methods and plumbing infrastructure. By using such tools, the developer can focus on the real functionality being tested, which can greatly improve productivity.

Functionally speaking, we analyze tools that automate mock usage, provide a wider number of assertion methods, use reflection to access private members of tested objects, and make DbUnit usage easier. Because these tools provide generic testing support, many of these features are provided by more than one tool. Such feature overlap might sound redundant (the classic NIH[1] syndrome), but this diversity allows you to choose the most appropriate tool for your needs.

1 Not Invented Here

19.1. Introduction

Let’s take a brief look at the tools analyzed and how to run this chapter’s examples. All of these tools are open source projects; some are active and mature, and others have been stalled in development for quite awhile.

19.1.1. Tools overview

19.2. Transparent mock usage

19.3. DbUnit integration

19.4. Assertions made easy

19.5. Using reflection to bypass encapsulation

19.6. Summary