Fork me on GitHub

SpecWatchr allows you to employ continuous testing with NSpec. SpecWatchr automatically runs impacted tests as you develop. It keeps you from breaking your concentration while you are developing your application. Ruby 1.9.2 is needed to run SpecWatchr. Instructions to get SpecWatchr working follow, let's start with a demo first (if you haven't done so already, it's probably a good idea for you to familiarize yourself with NSpec first):

Source on GitHub.

NSpec + SpecWatchr from Amir Rajan on Vimeo.

Getting Started

Installing SpecWatchr

This tutorial will walk you through installing SpecWatchr (and all it's related bits).

  1. Install Ruby 1.9.3 for Windows.
  2. Install Growl For Windows.
  3. Ensure that you have NuGet installed.
  4. Create a blank solution.
  5. Create a .Net 4.0 or .Net 3.5 class library that ends with one of the following Test, Tests, Spec, or Specs...eg: "MyApp.UnitTests".
  6. Open the Package Manager Console and type the following commands:

    PM> Install-Package nspec

    PM> Install-Package specwatchr

  7. After installations completes, create a class called describe_FirstTest.cs with the following content (build the solution to make sure you didn't make an errors):
using NSpec;
class describe_FirstTest : nspec
{
    void given_the_world_has_not_come_to_an_end()
    {
        it["Hello World should be Hello World"] = () => "Hello World".should_be("Hello World");
    }
}


Running SpecWatchr

Now that you have SpecWatchr installed and you know what source executes, we can start it up and watch the magic happen.

  1. The solution that you created with the steps above should be open (make sure you build it once just so we know we are at a good place).
  2. Run Growl for Windows
  3. Run "Start Command Prompt with Ruby" (it should have been added to your start menu when you installed Ruby 1.9.3)
  4. Navigate to the solution directory for the project you created in the above tests (via command prompt).
  5. Run the following command: sidekick.bat
  6. Now that specwatchr is fired up, save describe_FirstTest.cs (specwatchr will execute and should Growl that all tests are passing).
  7. This is a really nice Growl Theme that's worth installing: Translucent Dark.

Important Stuff

When you ran Install-Package specwatchr, a few ruby files got placed in your solution directory:

dotnet.watchr.rb

The file named dotnet.watchr.rb is your configuration file for specwatchr. Open it up in your favorite text editor to see configuration options (if you are using NSpec via Nuget, you shouldn't have to change anything in the configuration file).

watcher_dot_net.rb

This file contains all of the source for specwatchr. Anything you may want to tweek or customize can be done in this file (you'll find that you may want to customize specwatchr to fit your solution need once you get more familiar with what the code does).