0

I use SpecFlow with Coded UI to create automated functional tests for a WPF application.

I would like to create a Scenario Outline which loads Examples from a CSV file.

Scenario:

Scenario Outline: Demo_01
    When I press Login button
    When I have entered [<Username>] and [<Password>]
    When I press OK button
    Then I should be logged in as [<Username>]

Examples: 
| Username     | Password |
| user1        | pass1    |

Step Definition:

[When(@"I have entered \[(.*)] and \[(.*)]")]
    public void WhenIHaveEnteredLoginData(string username, string password)
    {
        UILoader.Main.EnterUsername(username);
        UILoader.Main.EnterPassword(password);
    }

UIMap class (MainUIMap.cs):

public void EnterUsername(string username)
    {
        WpfEdit uIUsername = this.UISoftwareWindow.UILoginView.UIUsername;

        uIUsername.Text = username;
    }

public void EnterPassword(string password)
    {
        WpfEdit uIPassword = this.UISoftwareWindow.UILoginView.UIPassword;

        Keyboard.SendKeys(uIPassword, password, true);
    }

It is possible to load the Examples from a CSV file? If yes, how (please provide code snippets)?

Thanks,

P.S.: The above presented scenario is for presentation purpose. I have some scenarios which should be executed with 500+ test data (which means 500+ Examples rows in Scenario Outline). I don't really want to ruin the visibility of my feature files so I would like to ask for your help.

LeeWay
  • 793
  • 3
  • 16
  • 28
  • You should do a web search for data driving Coded UI tests. However, Stack Overflow is not a free code design and writing service. You need to show some effort into doing the work yourself before you can expect any great assistance from us. As it stands your question is likely to be voted down and closed as not showing enough research on your part. – AdrianHHH May 13 '14 at 12:55
  • I know how to implement a data-driven test in a pure Coded UI test project. I would like to know if anybody done something like this with a SpecFlow+Coded UI test project and could share some information. I made a web search and I didn't found the answers, this is why I'm here. – LeeWay May 13 '14 at 13:51

1 Answers1

1

SpecFlow doesn't support such functionality.
One choice related to reading examples from file is to use SpecFlow+ Excel and read data from excel file.

drets
  • 2,583
  • 2
  • 24
  • 38