4.4. Incidental details

What makes code readable is that it reveals its intent, purpose, and meaning promptly and squarely to the reader. When programmers scan a block of code, they’re looking for the beef, and any sauce that gets in the way is unwanted. Sometimes our test code has too much sauce. We call that smell incidental details.

Let’s look at an example again. This is a longer one. Take your time to figure out what this test is trying to verify.

4.4.1. Example

The following is another example from the JRuby project. JRuby has a module called ObjectSpace. ObjectSpace gives your program access to all the living objects in the runtime. For example, you can iterate through all objects of a given type. The code in the next listing presents ...

Get Effective Unit Testing now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.