Apr 29 2011

NHJUG TDD Talk - Slides And Video

As I mentioned in a previous post, I recently gave a talk on Test Driven Development at the April NHJUG meeting. A few people have asked me for the slides so here they are. I experimented with recording the talk as well so you can see the results of that experiment as well.

At a high-level, the talk centered around the following topics:

  • What is TDD?
  • The developer workflow
  • In depth, live coding demo of the developer workflow
  • Some tips for test implementation, maintenance, and refactoring
  • Mocking
  • Lots of great interactive discussion from the audience!

The talk was a long one clocking in at over 2 hours so I appreciate everyone who hung in for the duration. There is a bunch of content in the slides that we didn’t talk about so you may find some interesting stuff in there even if you attended the talk.


Slides


Video

NHJUG Talk on Test Driven Development from David Ehringer on Vimeo.

While the talk was over two hours in length, this video captures just the first hour or so. So a bunch of topics as well as some of the great discussion are unfortunately not included in the video but you can see the slides above.

Sections:
0:45 - Background
4:40 - Agenda
6:15 - What is TDD?
8:40 - TDD Workflow
22:25 - TDD Workflow Demo
56:15 - Measuring TDD: Test Coverage, Code Quality, and Other Tools


Nov 7 2010

Parameterized Tests in JUnit 4.x

Parameterized tests is one of the features that have come along in the JUnit 4.x releases that I don’t find myself using very often but when I do, I find tremendously useful. In a nutshell, parameterized tests allow you to run the same test over and over again using different values. I’ve found this approach very useful when you are testing a function and have a table of data defining the input value(s) and the expected result. That being said, parameterized tests can be used for testing more than just pure “functions.”

This post walks through a detailed example of using JUnit’s parameterized tests.

Continue reading


Jun 10 2010

Unit Testing Singletons

The Singleton

I would say that I fall into the camp that generally shies away from the use of singletons.  To start, singletons are a form of global state that is to be avoided.  They carry state across the entire execution of the program making both testing and debugging difficult.  It becomes hard to execute tests in isolation because they may modify the state of the singleton in ways that undesirably ties tests to a strict execution order.  Beyond problems with global state, objects that use singletons are highly coupled to the both the way the singleton is instantiated and the way it is implemented.  It isn’t possible to test an object that depends on a singleton without testing (or in someway relying on the behavior of) the singleton as well.   Furthermore, this coupling is hidden from the user of the object.  To correctly interact with the class depending on the singleton, a dependency that is not explicit in its interface, you must often also understand the behavior of the singleton.  In other words, the state and behavior of the singleton can affect the behavior of the depending object as well as transitive side effects. Continue reading