Search code examples
c#testingbddspecflowspecrun

SpecFlow - Is there a way that i can run scenarios out of VS with values set by user input?


First of all i'm new here and new to SpecFlow. I'll try to be as clear as possible because I'm still exploring ways to solve my problems so please bear with me :)

Alright here I go. I have a solution (lets call it DBHelper) that does a few operations on a Database and i want to provide a tool in BBD (using specflow) to determine and set up a test suite using test rail that will run automatically. These tests could be a set composed of single scenario run several times but with different values. I'm still very early in the development of this tool so the version i have right now is connected to DBHelper and does a single operation when i run either SpecRun of NUnit.

Here is my scenario: Scenario: InsertBuildCommand

Given The build name is AmazingTest
And The build type is Test
And The platform is PC
And The number of files in the build is 13
And Each file is 8 MB
And The project code name is UPS
And The studio code name is MTL
And The environment is TEST
When The command executes
Then The build should be inserted in the DB with the correct files in it

Now i am looking fo a way to make the scenario dynamic. I ultimatelly want the user to enter be able to run the scenario but his choice of values (ex: the name of the build would be MoreAmazingTest) without being in VS. I know you can run SpecRun from the command line but i am clueless as to how to close the gap between the orignally hardcoded scenario values and the user input. The steps contain regular expression where it is useful so it really is just about the scenario values.

Someone told me about coding a custom plugin or reverse engineer Specrun and make a modified version of it but i have no idea how that would help me. Pardon me if it all makes sense i'm not en expert :x

Thanks alot!


Solution

  • If I understand your question properly, you can use Scenario Outline rather than Scenario. Scenario Outline help

    You would then have something like this:

    Scenario Outline: test using multiple examples
        Given I do something
        When I enter <numbers>
        And I click a button
        Then I will have an answer
    
    Examples:
    |numbers|
    |1      |
    |2      |
    |3      |
    

    It will then run the same scenario for each example given.