Running Specs from your IDE Edit on GitHub

There will be a "dotnet test" adapter for Storyteller in the VS 2017 timeframe that will make the following samples mostly unnecessary, but we're waiting for more VS 2017 adoption and stabilization.

Storyteller specifications will fail and there will be times when you're really going to want to be able to debug through your code while a Storyteller specification is running. While you can always attach a debugger to the running system under test when the Storyteller UI is running, it's a faster feedback cycle to be able to just start and run your specification from whatever IDE you are using.

In all cases, the code shown in this topic must be contained within your Storyteller specification project.

To that end, Storyteller 4.1 (re)introduces the StorytellerRunner class that you can use to execute Storyteller specifications from the IDE. If your Storyteller specification project does not have any kind of custom ISystem (i.e., you kick it off with StorytellerAgent.Run(args)), you can use this syntax:

public void run_spec()
    // There is an optional argument in this method to give
    // Storyteller a hint about where the project root folder
    // is, but in most cases it should be able to figure that
    // out on its own
    using (var runner = StorytellerRunner.Basic())
        // run one spec by its path as shown in the UI.
        // You can just copy/paste the full spec path
        // from the spec editor page in the UI
        var results = runner.Run("Arrays / Use an array argument");

        // You can open the results in a browser window

        // You can write the results to a file

        // Run all the specifications in the project

I use the venerable TestDriven.Net tool to run unit tests inside of Visual Studio.Net. One of its nifty features is the ability to run any arbitrary method in your code as well as run the method in the debugger. You may instead opt to add a unit testing tool like xUnit and kick off Storyteller specifications from a unit test where you have many more options for running the code.

If you are using a custom ISystem, use the syntax shown below to bootstrap the runner:

public static void Debug()
    using (var runner = StorytellerRunner.For<SpecificationSystem>())
        runner.Run("path to the spec");