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.



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.

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

Apr 21 2011

xml-matchers – Hamcrest Matchers for XML

I recently published a small, open source project that I’ve been messing around with for probably close to two years now but never got around to cleaning up and publishing. It’s called xml-matchers and is a collection of Hamcrest matchers for matching against XML documents. I primarily created it for testing but I’m sure you could find other uses for it. The project is hosted at Google Code: http://code.google.com/p/xml-matchers/.

The matchers allow you to do things like:

Source xml = ...
assertThat(xml, hasXPath("/mountains/mountain"));
Node xml = ...
String xml = "<mountains><mountain>K2</mountain></mountains>";
String xmlWithSpaceWrappingText = "<mountains><mountain>\n\tK2\n\t </mountain></mountains>";
assertThat(the(xml), isEquivalentTo(the(xmlWithSpaceWrappingText)));
Schema schema = w3cXmlSchemaFromClasspath("org/xmlmatchers/validation/example.xsd");
String xml = "<person private=\"true\"><name>Dave</name></person>";
assertThat(the(xml), conformsTo(schema));

Continue reading

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