O'Reilly logo

Pragmatic Unit Testing in Java 8 with JUnit by Jeff Langr, Andy Hunt, Dave Thomas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2Getting Real with JUnit

In the last chapter we wrote tests against a simple example class named ScoreCollection that calculates an arithmetic mean. Working through that exercise helped us get a good handle on JUnit fundamentals.

Pat wasn’t impressed, however. “All that effort to test a tiny class that averages a bunch of numbers? Real code isn’t so simple.”

True, Pat, although the previous chapter was more about getting you comfortable with JUnit. We could write more tests against ScoreCollection, but it’s time to move on to testing code closer to the reality of the average system.

In this chapter we’ll spend a little time looking at a meatier bit of code that we want to test. The analysis effort will help us to focus on writing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required