Peter Morris
Peter Morris

Reputation: 23224

Is it possible to load SpecFlow tests from a file?

I'd like to give a library + SpecFlow project to a client and let them add new SpecFlow scenarios without needing to generate source code / compile.

Is it possible to load a set of tests from a text file and run those?

Upvotes: 0

Views: 251

Answers (1)

Greg Burghardt
Greg Burghardt

Reputation: 18848

SpecFlow scenarios are just plain text files. There is nothing stopping your client from opening up Notepad or any other text editor and writing new scenarios or features. They could even just write them in an e-mail and send it to you.

Visual Studio and the SpecFlow extension just make it easier to write new scenarios, because it enables auto-complete for steps. If your client doesn't need step suggestions, then any text editor will do.

Once you have their new scenarios, you can add new feature files to your test project. This will enable the step bindings and allow you to run the tests.

If you want the client to write scenarios and be able to run them, you are out of luck. That isn't supported unless you create a windows app that imports your step definitions, test dependencies and then parses the feature files into test classes before executing them.

So, you can partially get what you want.

  1. Clients can write new scenarios in any text editor they want.
  2. You would need to copy those scenarios into feature files in your test project.
  3. You would be the one running the tests, not the client.
Feature: Clients writing their own scenarios
    In order to collaborate more openly and efficiently with the development team
    As a client
    I would like to write new BDD scenarios

Scenario: Client writes a new scenario in notepad
    Given the client has opened notepad
    When the client writes the following scenario:
        """
        Scenario: Adding comments
            Given a blog post titled "Today's weather" was written
            When a reader comments on "Today's weather"
            Then 1 comment exists on the blog post titled "Today's weather"
        """
    Then the client has written a scenario titled "Adding comments"
    But the client cannot execute the scenario

Upvotes: 1

Related Questions