Monday, July 1, 2019

API Testing 06: Introduction REST- assured and creating a REST-assured - Maven project

REST-assured is a java API for testing and validating the RESTful Web services in Java. It is developed and maintained by John Haleby with the help numerous open source contributors.


REST-assured is easy to understand, simple to use, yet very powerful API for API testing. REST-assured provides many in-built functions, those functions provides flexibility to automate complex scenarios. It also supports integration with plugins like Hamcrest for easy response validations.

It supports BDD style scripting, which increases the readability. With less scripting we can write powerful tests. We will see all the important features of REST-assured in upcoming tutorials.

Configuring REST-assured project:

Create a Maven project in IntelliJ IDE and add the Maven dependencies of REST-assured, JSON Path and TestNG in pom.xml.

BDD Style in REST-assured:

Rest-assured uses an API that supports BDD style in writing the tests. This style increases the readability of the tests.

We will be using the tests using the Gherkin language keywords "Given-When-Then" as functions. Some of the keywords are discussed below
  • Given:  This takes given context, state or parameters of system
  • When: It looks for a state or condition to happen/when something happened
  • Then: It verifies the new state of the system or outcome
  • And: It is used for conjunction of more than one condition
  • Scenario: It is used for describing the test case
  • Background: This is used for executing the pre-requisite steps of each scenarios.
In the next tutorial we will learn about writing the our first test case using REST-assured in BDD style.

#HappyLearning #HappyTesting

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I will prefer this blog because it has much more informative stuff. Visit Google Search Api for more related information and knowledge.

    ReplyDelete

Selenium4: Working with two parallel windows in Selenium Automation

A new method newWindow() is introduced in Selenium 4 (Alpha). Using this method we can open a new tab or new window from the current window...