3
votes

I've recently started working on a project with which I want to try Behavior-driven Development. I have chosen SpecFlow as my testing framework since it's a C# application. From what I gathered reading on this topic on the net, one upside of BDD over TDD is that BDD can be used to test one's UI. However, I am having some trouble doing this with SpecFlow. For my first test, I wanted to write the following functionality:

A user clicks a button that presents him with a FolderBrowseDialog, after selecting a folder the application searches the folder for files relevant to the application and loads those files into the application.

The following scenario is more or less what I want to write:

 Scenario: Add Model
 Given I am on the main screen
 When I click Add Model
 And select a folder
 And the folder contains a model
 Then the model is loaded into the application

What code do I need to have SpecFlow click stuff on that FolderBrowseDialog to complete this test?

1

1 Answers

4
votes

Specflow cannot automate your UI on its own. SpecFlow is a BDD framework which allows you to write you tests using the Gherkin syntax (SpecFlow is a .Net implementation of Gerkin) and will execute them for you. However you have to implement the code that will perform the actions that each step requires.

You need to use a web UI testing framework to automate the UI steps in your specflow scenario. Examples of such scenarios are Selenium, WatIn etc

Edit

sorry misread the question, you are not doing web UI automation but just UI automation so then you need a desktop UI framework I assume (its not clear what environement you are running on, but I'll assume windows). One I am aware of is White although you could also use the microsoft UI testing framework coded UI. The same principals apply though.

Once you have chosen a framework then you need to plug the relevant actions into each specfloe step so that the chosen actions are performed during each step.

Don't be put off though, SpecFlow is an excellent framework IMHO and you will not regret going down the BDD appraoch in the long run.