Question

I am trying to understand when should you test via BDD such as cucumber/specflow, and when should you test your gui directly.

For example, the test "the AdminHelp button should only be seen by an administrator".

This admin button is on a particular page. Should I test it in a BDD fashion (i.e. the scenario where:

  1. When an Admin Logs in
  2. Then he sees the AdminHelp button

or

write a unit test that sets current_user to an admin user, and test whether the html rendered by the template includes AdminHelp button or not.

Thanks.

Était-ce utile?

La solution

Specflow is an automation tool, but it works on a higher level than, say, Selenium or Microsoft UI Automation. You would normally use it to describe a scenario in which a user uses the application. For instance:

Given Andy Admin is an administrator
When he logs in
Then he should be taken to the admin home page.

Given Andy Admin is on the admin home page
When he wants help
Then he should be directed to the admin manual.

Notice that I haven't mentioned the admin help button anywhere in there. Andy could quite easily have asked a secretary for help! We're describing the steps declaratively, in terms of the capabilities provided by the system. This is the style of BDD.

Specflow then maps the Given, When and Then phrases to code steps. In the code, you can use automation tools to actually click the button. However, it's far more maintainable to use the same language that the business use to describe the system's capabilities; because then, if the UI changes, you only need to change 1 step and not 15-odd scenarios.

Also, using the higher-level language in the scenarios tends to keep the business interested, which means it's much easier to have conversations with them about those scenarios. Conversations are at the heart of BDD, and I suggest starting there, before worrying about how to do the automation part.

Autres conseils

You should because this is part of the UI/UX acceptance criteria. And you could do it in BDD fashion. You can use cucumber/specflow at different abstraction level.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top