Forum Discussion

sijianand08's avatar
sijianand08
Occasional Contributor
6 years ago

BDD

Hello,

 

Can someone help to how to achieve BDD approach in ReadyAPI?

 

Thanks

Siji

5 Replies

  • richie's avatar
    richie
    Community Hero

    Hi,

     

    Can you clarify what you mean by a "BDD approach"?

     

    I'm assuming you don't just mean creating BDD test cases....but a bit more info - some context to your request and exactly what you need - could only help people help give you an answer that may help! :)

     

    Cheers,

     

    richie

    • sijianand08's avatar
      sijianand08
      Occasional Contributor

      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?

       

      • richie's avatar
        richie
        Community Hero

        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