sijianand08
6 years agoOccasional Contributor
BDD
Hello,
Can someone help to how to achieve BDD approach in ReadyAPI?
Thanks
Siji
Hi,
This was a request from team they need BehaviourialDataDriven approach in api testing.And most of our testcases are in ReadyAPI so checking is there anyway to incoporate?
Hey sijianand08
erm - bit confused. Do you mean Behaviour Driven Development? you mention "BehaviouralDataDriven" and I dont know if we're talking about the same thing!
If you are talking about Behaviour Driven Development - see below
BDD (Behaviour Driven Development) is a design/development/test approach to software development and the focus is defining how the system works from the perspective of the user by the BA/Product Owner and supports the creation of tests BEFORE the code has been developed.
Code is then run against those tests and updated as per any failures that are identified. Its an approach used quite often in agile projects.
The User stories in BDD are created using the GIVEN, WHEN THEN approach.
BDD test cases are devised and organised using the same approach
e.g.
GIVEN that the logged on user is a member of the Administrator role
AND has launched the User Adminstration page
WHEN the user performs appropriate action to create a new user with a Adjudicator role
THEN the new user is successfully created as a member of the Adjudicator role group
I've never used BDD in my API testing before and I've never worked on projects where BDD is used in the API testing. I've worked on projects where the front end automation uses BDD test cases - but Im unsure if it really fits with API testing - the major reason being that BDD is supposedly testing the application from the perspective of the user - and API testing for the most part doesnt equate to this.
I suppose you could try and use the GIVEN, WHEN, THEN approach to your API test design - but I suspect it wouldnt add much value by using this approach and would slow you down initially as you are devising your tests with a new structure which takes a couple of hours to get used to.
I suppose you could try something like the following:
Positive test to create a new user via a webservice submission
GIVEN a .json is submitted to the listening web service via an HTTP POST
WHEN the .json has been configured to create a new user
THEN a 204 http status code is returned
Associated negative test
GIVEN a .json is submitted to the listening web service via an HTTP POST
WHEN the .json has been configured to create a new user, except the UniqueReference attribute is blank (UniqueReference attribute is has mandatory data population requirement)
THEN a 400 http status code is returned
HOWEVER - if you're using ReadyAPI!/SoapUI - the GIVEN and WHEN detail comprise the summation of the content of your .json request and the THEN are your assertions - so it doesn't really make any difference - BDDs are just a way to structure your tests so they're easily understandable/readable.
ALSO - if you are talking about Behaviour Driven Development - considering the tests are supposedly devised from the users/customers perspective and API testing really doesn't support this - have you questioned the person who asked you to adopt the approach how they think it would fit with API testing?
Ok - thats it - just my opinion - perhaps the other API testers on the forum have a different one?
Cheers,
richie
My Bad its Behaviour-Driven Development (BDD) what you had explained yeah even I have gone through some of the documents and got to know about CUCUMBER tool and how they designed.
As you gave an example field mandatory they should have some message saying why test failed(through code) but team doesnt want to see that instead test result has to be understanble by anyone so am assuming it is BDD .So curious if anyone had this kind of need before.
Thank you so much for your reply!
Hi sijianand08,
SmartBear has a great tool for BDD - Hiptest. BDD allows you to describe your test by using a natural language. However, if you want to automate such tests, you will need to create them in a special tool. We have just released TestComplete 14 that supports recording automated tests based on BDD steps. So, by using TestComplete you can record tests. If you need to test APIs, you can implement such tests in ReadyAPI and call them from TestComplete. However, TestComplete is a more universal tool that may help you record different types of tests.