Image from Pragmatic Title: Pragmatic Unit Testing in Java 8 with JUnit Author(s): Jeff Langr
Pragmatic wrote:The Pragmatic Programmers classic is back! Freshly updated for modern software development, Pragmatic Unit Testing in Java 8 With JUnit teaches you how to write and run easily maintained unit tests in JUnit with confidence. You’ll learn mnemonics to help you know what tests to write, how to remember all the boundary conditions, and what the qualities of a good test are. You’ll see how unit tests can pay off by allowing you to keep your system code clean, and you’ll learn how to handle the stuff that seems too tough to test.
“Pragmatic Unit Testing in Java 8 with JUnit” covers JUnit 4 and a mix of Java 7 and 8. JUnit 5 wasn't out yet when the book was written so the decision to cover JUnit 4 makes sense. There was good coverage of assertThat along with three stycles of exception testing.
There were some Java 8 idioms used include functional interfaces, method references, streams and lambdas. There were also some places that could have used lambads and didn't. For example, chapter 8 makes a big point of refactoring to make the code cleaner. But then the anyMatches/matches methods use a loop.
The narrative about Dale testing and Pat the skeptic added nice color. Each chapter ends with a short “After” section that provides a mix of summary and transition. I also liked the technique of using arrows to show what changed in each refactoring and edition. Testing concepts were covered well including the FAST, Right BIPCEP and CORRECT acronyms.
I think the book was great. It's a timely updated to the original Pragmatic Unit Testing book (which uses JUnit 3.8.) But I have to take off a tiny bit for the fact that Java 8 looks to have been retrofitted in.
I give this book 9 out of 10 horseshoes.
Disclosure: I received a review copy of this book from the publisher for reviewing it on behalf of CodeRanch.