Setup


To kickstart this tutorial, we've created a "Hello World!" project with the following structure.

Download: concordion-net-kickstart.zip

Structure

It contains the latest stable version of Concordion.NET, all its dependencies, and a simple "Hello World!" example.

  1. "Greeter.cs" is the class we want to test
  2. "Kickstart.Spec" is a Visual Studio project for the specifications and acceptance tests. Unit tests are typically held in a project ending with "Test" but we prefer the name "Spec", for the Concordion.NET acceptance tests, to emphasize the fact that these tests are concerned with external behavior.
  3. "HelloWorldTest.cs" is a Concordion.NET test fixture class. We'll explain how this works, below.
  4. "HelloWorld.html" is the Concordion.NET specification and is processed by the "HelloWorldTest.cs" fixture. The name of the fixture and the HTML file share the same base name. The fixture has an optional suffix of "Test" - for example, it may be named "HelloWorld.cs" or "HelloWorldTest.cs".
  5. "concordion.css" is a stylesheet to make the specs look nice while you're writing them.

Concordion.NET requires the .NET framework with version 3.5 or higher. You have to add the following references to your project:

To be able to run the Concordion.NET tests with NUnit you need to make the Concordion-NUnit addin available to your installation of NUnit:

These dependencies are included in the distribution.

The Basics


A Concordion.NET executable specification consists of two parts:

  1. a well-formed XHTML document describing the functionality, and
  2. fixture code written in C#  that relies on concrete examples from the specification document and uses them to verify the system under test.

Both files must be in the same package. In order for the magic to happen, the document must first be instrumented with commands. Concordion.NET commands are specified as attributes on elements in the XHTML document. Web browsers ignore attributes that they don't understand, so these commands are effectively invisible.

The commands use a "concordion" namespace defined at the top of each document as follows:

<html xmlns:concordion="http://www.concordion.org/2007/concordion">