# REST Assured

Rest Assured is an <mark style="background-color:yellow;">**open-source Java library**</mark> that makes testing RESTful web services simple. It allows you to:

* Validate response status codes
* Validate headers
* Validate response body (JSON, XML)
* Perform authentication
* Parameterize requests

## Some main features of Rest Assured:

* Request building - Easily build HTTP requests using a Domain Specific Language rather than manual header/body setup. Saves time.
* Response validation - Inspect response status, body, headers and validate against expectations. Ensures API works as intended.
* Parameterization - Externalize test data and define parameters for data-driven, maintainable tests across browsers in parallel.
* Pre/post request specification - Define authentication, common headers etc. once to avoid duplication in each test case.
* Response extraction using JSON path - Query and extract specific response values for assertions or for use in next request. Handy!
* Assertions library - Validate responses using Hamcrest or JUnit matchers for clear pass/fail results in a readable manner.
* Logging filter - Log request/response details across tests for easy debugging. Like recording an experiment!
* Pretty printing - Print response in pretty/formatted JSON or XML rather than one long string. Makes visualizing responses simpler.
* Interactive documentation - Automatically generate API documentation from tests. Great for code documentation and collaboration.
* Test runners - Integrate tests with popular runners like JUnit to execute automated regression suites on multiple browsers or servers in parallel.

## Postman vs Rest Assured ⚖️

<table data-full-width="true"><thead><tr><th>Postman</th><th>Rest Assured</th></tr></thead><tbody><tr><td>User interface</td><td>Code based</td></tr><tr><td>Manual + automation</td><td>Automation only</td></tr><tr><td>Language agnostic</td><td>Java specific</td></tr><tr><td>Broad API testing</td><td>Focused on REST</td></tr></tbody></table>

## Using Postman and Rest Assured 🤝

They can be used together:

* Postman to prototype APIs 🚀
* Rest Assured to automate tests ⚡️
* Postman provides UI, Rest Assured provides a programmatic interface 💻➕📲
* Combined they streamline API testing 🏃‍♂️
