Working Effectively with Unit Tests

Unit Testing has moved from fringe to mainstream, which is great. Unfortunately, developers are creating mountains of unmaintainable tests as a side effect. I've been fighting the maintenance battle pretty aggressively for years, and this book captures the what I believe is the most effective way to test.

Unit Testing has moved from fringe to mainstream, which is great. Unfortunately, developers are creating mountains of unmaintainable tests as a side effect. I've been fighting the maintenance battle pretty aggressively for years, and this book captures the what I believe is the most effective way to test.

This book details my strong opinions on the best way to test, while acknowledging alternative styles and various contexts in which tests are written. Whether you prefer my style or not, this book will help you write better Unit and Functional Tests....more

I wish every developer I work with had read this book (including the past me). It distills into a surprisingly short amount of pages many important lessons that I've learned the hard way over a number of years. For a beginning or intermediate unit tester this book is a must-read. The most experienced unit testers may not find much new in it, but even they can benefit from seeing unit testing from the author's unique point of view.

What sets this book apart is its hands-on approach. You're thrownI wish every developer I work with had read this book (including the past me). It distills into a surprisingly short amount of pages many important lessons that I've learned the hard way over a number of years. For a beginning or intermediate unit tester this book is a must-read. The most experienced unit testers may not find much new in it, but even they can benefit from seeing unit testing from the author's unique point of view.

What sets this book apart is its hands-on approach. You're thrown right into the deep end with a painfully realistic example. A bunch of tests have failed and it's your job to figure out what went wrong by reading the test output, the test code, and the code under test. This dreadful task gives you a very tangible impression of what it means for a test suite to be maintainable: the better the tests, the faster you'll be done.

In the rest of the book the author points out features of the test suite that make it hard to work with and demonstrates refactorings that alleviate the problems. There's nothing abstract about why each change makes the tests better. You can clearly see that with each new version the cause of failure becomes much easier to find. Sometimes this approach might lead to surprising solutions, for example, introducing duplication into DRY code, but you can't argue with results.

I found the book's objective approach to (test) code quality refreshing. As always in design, some decisions are simply a matter of taste, and the author makes it clear when what he's presenting is simply his preference.

This is one of my favorite books on testing, and if I could recommend only one, this would be it....more

A quick, enjoyable read. The focus of the book is how to improve ROI of your unit tests, and provides helpful suggestions to achieve this. There is no dogma here, nor anything revolutionary, but it's a solid addition to the testing literature.

If I have to list a downside, it's that all the examples are Java, and I wonder if some of the patterns are less valuable in other (say dynamic) languages. I would have loved to hear the author's thoughts on this, but it's a minor quibble, and I would stillA quick, enjoyable read. The focus of the book is how to improve ROI of your unit tests, and provides helpful suggestions to achieve this. There is no dogma here, nor anything revolutionary, but it's a solid addition to the testing literature.

If I have to list a downside, it's that all the examples are Java, and I wonder if some of the patterns are less valuable in other (say dynamic) languages. I would have loved to hear the author's thoughts on this, but it's a minor quibble, and I would still recommend this book to any engineer, no matter what languages they use....more

This is a book I plan on strongly recommending to other developers. Jay Fields presents his strategy for testing and his definition of a unit test. The book starts with some marginal unit tests and slowly improves them. I found myself feeling uncomfortable with the initial version of the tests and it was rewarding seeing the tests improve and having that uncomfortable feeling disappear.

Why do you write tests? What do you try to get out of testing? How do you make failing tests useful? By the timThis is a book I plan on strongly recommending to other developers. Jay Fields presents his strategy for testing and his definition of a unit test. The book starts with some marginal unit tests and slowly improves them. I found myself feeling uncomfortable with the initial version of the tests and it was rewarding seeing the tests improve and having that uncomfortable feeling disappear.

Why do you write tests? What do you try to get out of testing? How do you make failing tests useful? By the time you finish this book you should have a been driven to think about those questions and more. Even it you don't agree with Jay's approach this book will make you think.

As someone who has done TDD for 10+ years, this book still taught me a few new things and made me reconsider how I like my tests setup. I really like the format of the book - by clearly addressing readers already experienced with testing Jay manages to keep the book short and information dense in a way I wish more technical writers would.

An opinionated masterpiece about how to write maintainable unit tests. This book contains lots of details and well thought-out practices. Highly recommended for those who want to step up their game when it comes to unit tests and TDD.

Jay Fields uses in Working Effectively with Unit Tests a different approach than most authors that write about TDD: How does test-driven development creates value? As a measurement to judge the different approaches he uses ROI (return on investment) and explains the different side-effects certain styles of tests have. This (at least for me) new way to look at TDD is refreshing and helps to stay away from code bases that are impossible to change after an endless amount of tests are written that nJay Fields uses in Working Effectively with Unit Tests a different approach than most authors that write about TDD: How does test-driven development creates value? As a measurement to judge the different approaches he uses ROI (return on investment) and explains the different side-effects certain styles of tests have. This (at least for me) new way to look at TDD is refreshing and helps to stay away from code bases that are impossible to change after an endless amount of tests are written that no longer justify the cost of maintaining them.

Be aware that the first examples he shows are only intermediary steps to a good solution. The first reaction after the initial refactoring may be “oh no!”. But those examples are only there to explain the problems and when you keep reading the code gets better and better. Maintaining a big code base with lots of tests is hard work. Applying a metric like ROI to challenge all tests and cutting them back on a regular basis is a good advice that will make your life simpler. When you do TDD you definitely should read this book. And when not this book may be give you a reason and a tactic to start writing more and better tests....more

Great book. Jay did a great job of providing excellent examples and explanations behind why he is changing those tests. Another great thing about this book, that it's 330 pages but they are all about testing, and no history or other unrelated to testing material.

The book is very pragmatic and short. Pretty nice overviews dos and don'ts of unit testing. With excellent examples to prove the points. But I would recommend to read "Growing object oriented software guided by tests" by N. Price first

Great book, but my only quibble is that using Java for the examples requires much more code for writing tests than in a more dynamic language. I definitely learned a lot about designing unit tests, useful in any language.

Meh. It's good. It's probably directed to people that have been using unit tests for a very long time and use them extensively, which is not my case. It does have good info, it's probably that I don't know enough to get all of this book.

Jay Fields is a software developer at DRW Trading, conference speaker, and author. He has a passion for discovering and maturing innovative solutions. His most recent work has been in maturing software design through developer testing and software testing in general.