Automating Behavior Driven Development (BDD) using NoCodeBDD is as easy as pie. Using NoCodeBDD to automate BDDs will take minutes rather than hours as there is no code involved in the automation. In this article, we will look at how NoCodeBDD can be used to call a REST API and how the response from that REST API is asserted.
For the purpose of this article we will be using the following API:
Write your Feature File
As a first step, let’s write our Feature file. We will write a scenario to validate a REST response status and REST response message.
The scenario is self explanatory. One thing that might be worth explaining is, in the last step, we want to check entire message response from the API. Hence the reason for not passing values via the step. Passing values via the step is a simple process using NoCodeBDD, which is explained here https://wordpress.com/block-editor/post/nocodebdd.blog/21
Scenario 1: Call a REST API using GET and assert the status as 200 and message returned
When NoCodeBDD User Info REST API is called using GET
Then Response status should be 200
And Response from REST API should match all values as expected
Following GIF shows how the above Feature File is written in NoCodeBDD
Following sections show how the Feature file is automated without any code
Call REST API
For the Step “When NoCodeBDD User Info REST API is called using GET”, we need to call a REST API using GET HTTP method. In order to do that:
- Click the burger menu next to the Step and then click on “Step Definitions”
- Then click on “New Step Definition” button
- Then select “REST” and click Next button
- Then select “Send API Request” and click Next button
- Then select Request Type as “GET” and enter the URL as “www.freeapi.nocodebdd.com/simpleGETAPI/userinfo” and press Save button
That’s it! You have completed automating a Step using NoCodeBDD. The above steps are shown as GIF below:
Assert REST API Response Status
For the Step “Then Response status should be 200”, we need to assert a REST response status. Following GIF shows how it is done.
Assert REST API Response Message
For the Step “And Response from REST API should match all values as expected”, we should assert the entire message to make sure it matches what is expected. This is shown in following GIF:
Congrats! You have automated a REST API using NoCodeBDD in minutes and without writing any code. Automation is of no usem if you can’t run. Following section shows how it is done through click of few buttons
Run your Automated BDD
Using NoCodeBDD, you can simply click the play button to run a Feature(s) or a Scenario. You can also view the request and response to the REST API. This is shown in following GIF.
If you would like to see what request and response messages are sent and received, you can simply click the i button and see the details. Following GIF shows how you can view the Request message that was sent in the step “When NoCodeBDD User Info REST API is called using GET”.
<Haritha – Show the GIF and highlight (in filmora you can do that) the request message>
Following GIF shows what response message was received
<Haritha – Show the GIF and highlight (in filmora you can do that) the response message>
Finally, you can view the results of the Feature that you ran and any of the historical run stats by simply clicking the Report menu and select the one you would like to view as shown in GIF below:
As you can see, rolling out Behavior Driven Development and automating it is extremely easy using NoCodeBDD. The basic version of NoCodeBDD, allows you to create unlimited Features and Scenarios. You can download the version from www.nocodebdd.com/download
Jerome Josephraj is the Founder and CTO of NoCodeBDD. He has more than 20 years of experience in Software Development and have been rolling out Behavior Driven Development for large projects in United Kingdom. He has a strong Java Development Background and have been working as a Technical Consultant. In one of his recent large enterprise projects, he has successfully rolled out Behavior Driven Development consisting of more than 1000 scenarios. He was also the Founder of http://www.campusinteraction.com, a student analytics portal, which was later bought by Preludesys. Based on the previous start-up experience and a strong Behavior Driven Development experience, he founded NoCodeBDD to improve efficiency of rolling out Behavior Driven Development by 10x.