Chris Hartjes has taken some of his first steps to testing a web service with the help of the Behat BDD testing framework. In this new post he shares some of that knowledge and a bit of code to help guide you if you'd like to get started yourself.
He shows how to define a "scenario" in a more recognizable sort of English. His example is testing a web service to ensure of a few things:
- the response is JSON
- it contains at least one transaction
- the first transaction has an ID, contains two teams and has a description
Included in the post is the resulting Behat test code (generated and modified with his testing details) and an example of the execution of the test.
I think that the BDD approach maps better to a results-oriented methodology when it comes to testing: you are using real-life scenarios to make sure that you are getting back the results you are expecting. In the end. that is still the goal of testing.