I'm writing acceptance tests for a web application using Behat/Mink.
I want to know best practice for testing strings in the GUI. For example: say I want to test that a link exists on the homepage to the login screen, by looking for a link with a text, such as "Log In".
I want to make it robust; at the moment, for example, I am testing for the presence of the link by hard coding the text of the link into the scenario:
Feature: Website Nagivation To use the website As a website visitor The nagivation needs to work Scenario: Check that the login link exists on the homepage Given I am on "/" Then I should see a link labelled "Log In"
Obviously this is really fragile. If the link's text is changed to "Sign In" then the test would break. (Among other problems, e.g. if the site is internationalised, the problem would be multiplied).
What strategies can I use for this? For example:
- Should I keep the data DRY, so have the strings used to populate the GUI come from the same place as the strings used to test, and refer to the string by some unique identifier?
- How could this be made most user-friendly for the writers/readers of the Gherkin/Behat acceptance tests?