Feeds:
Posts
Comments

Posts Tagged ‘example’

In the previous post in this series (“last week” to those who didn’t read it over a year ago), I made simple code complicated in the effort to make it unit testable. It was all going along fine, until I started bringing functional programming into the mix. Since that worked so well, I’m going to […]

Read Full Post »

In previous discussions about mock-free unit testing, I’ve shown techniques that I use to eliminate the hard-to-eliminate test doubles. I’ve skipped the simple techniques that I apply all the time. Time to fix that. One technique eliminated about 90% of the test doubles in my code. It’s simple. It’s been around for a long time. […]

Read Full Post »

In my character printer, at one point I had someĀ code like this monstrosity. I know it’s a monster, because testing it Requires at least one test double (the _character field). Involves running a bunch of code not related to the unit test at hand. Many people don’t think this code is so bad. They discuss […]

Read Full Post »

One of the common uses for mocks is to replace expensive or stateful components, such as file systems, networks, GUIs, and databases. However, I also see a cluster of other problems that arise at interfaces with these types of components, especially when they are system-level services: Primitive obsession. Rarely are these APIs written as methods […]

Read Full Post »

Previously, I presented mocksĀ as nuclear weapons. Unsurprisingly, commenters wanted examples. I exist to serve. This series will discuss a partly-completed project that I have lying around. The project isn’t perfect. But it will serve to discuss some of the ideas. Since it’s only partly complete, some ideas visible in this stage that would likely become […]

Read Full Post »