Running Fitnesse.NET tests using MSTest – Revisited

In 2008 I wrote a post Running Fitnesse.NET tests using MSTest.  Recently I had need to us this technique on a VS2010 project, and as is so often the issue the code that worked then does not seem to work now. All I can assume is that the Fitnesse API had altered, but I thought I was using the same assemblies!

So I pulled down the code from http://sourceforge.net/projects/fitnessedotnet/ and had a poke about. Basically I seemed to be using the command line switches wrong. The listing below shows what I found is the working usage:

[TestMethod]

    public void WorkFlowSwitchOnName_DataViaFitnesse_Success()

    {

        fit.Runner.FolderRunner runner = new fit.Runner.FolderRunner(new fit.Runner.ConsoleReporter());

        var errorCount = runner.Run(new string[] {

                "-i",@"WF Workflow", // the directory that holds the HTM test files

                "-a",@"TestProject.dll",  //we have the fit fascard in this assembly

                "-o",@"results"}); // the directory the results are dumped into as HTML

        // fit can fail silently giving no failures as no test are run, so check for exceptions

        Assert.AreEqual(false, Regex.IsMatch(runner.Results, "^0.+?0.+?0.+?0.+?$"), "No tests appear to have been run");

        // look for expected errors

        Assert.AreEqual(0, errorCount, runner.Results);

        

    }

The –i option is the one that was wrong. I had been specifying a single HTM file. What I should have done was specify a directory that contains one or more HTM files. I handled this as a sub directory in my project with its contents set to copy to the output directory.

Once I made these edits I had my tests running again as expect.