Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to run Specflow scenarios in desired order (C# Selenium)?

I'm trying to run multiple Specflow tests in the Test Explorer, but the challenge is I'm unable to run them in the desired order.

ex - I have 3 scenarios in my feature files:

  • Login positive
  • Login negative
  • registration positive

Currently, they run in random order. I want them to always run in the above order. How can I configure my feature files to make it possible?

like image 270
Rhythm Kalra Avatar asked Apr 20 '18 13:04

Rhythm Kalra


2 Answers

For NUnit: Tests inside a scenario run in alphabetical order, so if you want to run them in specific order just rename scenarios like

Scenario: 1 Login positive
Scenario: 2 Login negative
Scenario: 3 Registration positive

For other frameworks look here: https://www.ontestautomation.com/running-your-tests-in-a-specific-order/

like image 94
applekate Avatar answered Nov 20 '22 12:11

applekate


I also think it is so annoying if the tests order in the feature files different than the text explorer. So here is my solution to that.

Scenario: 01) Create test data
    Given ...
    When ...
    Then ...
    
Scenario: 02) Modify data
    Given ...
    When ...
    Then ...

Scenario: 03) Remove modified data
    Given ...
    When ...
    Then ...

Source

like image 39
Bashir Momen Avatar answered Nov 20 '22 10:11

Bashir Momen