How to run a single Specflow scenario in Resharper
Asked Answered
C

3

10

I am using Specflow (http://specflow.org/) to write some integration tests and I would like to run a single Scenario. Is there any way to run a single scenario with Resharper 6? BTW I configured specflow to use MSTest.

My Specflow test looks like:

Feature: Customer management

Scenario: Add a new Customer into system
    Given the User has entered the customer with the following data
    | name  | last_name | birthday   |
    | Peter | Stein     | 12.09.1955 |
    When the User has pressed the Save Button
    Then the following customer should be stored in the data base
    | name  | last_name | birthday   |
    | Peter | Steim    | 12.09.1955 |

Scenario: Second scenario.....

Scenario: Third scenario.....

I want to run only the first scenario.

Conroy answered 27/2, 2012 at 18:40 Comment(0)
C
10

If you are running with ReSharper as I am I just open the Feature file the right-click anywhere within a Scenario and select "Run Specflow Scenarios" from the pop-up menu. It runs just the one scenario you are in.

Please note, I am using ReSharper to run the tests.

Cataclysmic answered 4/3, 2012 at 22:0 Comment(0)
G
1

what i do is pop open the generated c# file and find the generated test there and use my keyboard shortcuts i have set up for the resharper test runner to execute the specs (and could use the green/yellow balls with the mouse too). it's less than ideal and i agree it would be awesome if you could just execute from the feature file. i haven't found anything like that out there. would be a worthwhile project to try to figure out a way to make that happen with a plugin. not sure what that would take.

Goosy answered 2/3, 2012 at 13:8 Comment(0)
C
0

Each Scenario should end up becoming one MSTest. In ReSharper, I typically go into the Unit Test Explorer (Control+Alt+U), make sure the Group by is set to Projects and Namespaces, then navigate down to my Acceptance Test project, open up the namespace for my feature (I group feature files in directories to put them in matching namespaces), and expand the feature to see all of the individual tests/scenarios. Selecting just one of those and clicking the Run or Debug button should execute that one test.

Confound answered 27/2, 2012 at 22:44 Comment(4)
Hi Michael, thanks for your answer. That is a good solution but it seems to be a work around. What I am looking for is a plugin or another way to run the scenario like they a unit tests.Conroy
I'm confused by your comment. SpecFlow turns each scenario into a unit test. My answer was explaining how you can run a single unit test, which is precisely one scenario. Perhaps I don't understand what you are looking for...Confound
Hi Michael, you are right, specflow translates every Scenario into a unit tests and your suggestion works. However I was thinking on a solution where I select a Scenario in the editor and I run it. For example with resharper when editing unit tests we have a green point on the side in order to execute it. With your suggestion I have to search for the generated unit test and it takes some time when I have a lot of Scenarios. Maybe I am looking for an option that it is not still implemented in Resharper. Do you know what I mean?Conroy
Ah, now I understand what you're asking for. I've looked for the same thing before to no avail.Confound

© 2022 - 2024 — McMap. All rights reserved.