How to Build a REST Assured API Testing Framework

267.2K views
•
March 16, 2023
by
SDET- QA
YouTube video player
How to Build a REST Assured API Testing Framework

TL;DR

A test automation framework organizes all project-related files (URLs, endpoints, payload classes, data-driven test cases, reports) with three goals: reusability, maintainability, and readability. Building one follows set phases: understand requirements via functional specs and Swagger, choose a tool, design the folder structure, develop it, then execute with CI. The tutorial automates the Petstore API using a hybrid-driven framework.

Transcript

foreign so from today we are going to start  framework development and framework   design and development so first of all let  us see what is framework and why we need a   framework and then now we'll see how we can  create folder structure and also we will see   step by step implementation of rest assured  framework so first of all what is framewo... Read More

Key Insights

  • A framework is a structure that maintains all project-related files such as URLs, endpoints, payload classes, data-driven test cases, and reports so they stay organized throughout an automation project.
  • The three main objectives of designing a framework are reusability (reuse components multiple times), maintainability (others can add or modify test cases later), and readability (anyone can read and understand the code).
  • A hybrid-driven framework is a combination of any two other framework types, such as data-driven plus modular or data-driven plus keyword-driven, and is the type used in this tutorial.
  • The first phase of framework development is understanding requirements thoroughly using functional specifications and Swagger documentation, which clarify what URLs, request formats, and responses to expect.
  • REST Assured and Selenium are libraries, not tools, because they are bundled collections of JAR files, classes, and methods that you download and use in automation rather than standalone installed applications.
  • The framework development phases run in order: understand requirements, choose the automation tool, design the folder structure and files, develop and implement those files, then handle execution plus continuous integration.
  • Tool selection depends on multiple factors including budget, the test team's skill set, and the technology used to design the APIs, and most API testing tools available are open source.
  • Manual test cases must be prepared and reviewed before automation begins; for the Petstore API the models Pet, Store, and User are treated as separate modules, and the tutorial starts with the User model.

Explore YouTube Video Summarizer or Get YouTube Transcript Extractor

Questions & Answers

Q: What is a test automation framework and why is it needed?

A framework is a structure that maintains all project-related files in an automation project. When automating test cases you accumulate many files: different URLs and endpoints, payload classes for each model, data-driven test cases, and reports. A framework keeps all of these organized. It is needed because automation involves many moving parts that must be maintained properly, and without a framework there is no reusable, maintainable, or readable structure to hold them together.

Q: What are the three main objectives of designing a framework?

The three main objectives are reusability, maintainability, and readability. Reusability means once you create a class or reusable component, it can be executed or used multiple times. Maintainability means that after you design the framework, another person can use it, add more test cases, or modify existing ones. Readability means anyone can easily read and understand your code and the framework itself. These three goals guide every decision made while designing the framework.

Q: What is a hybrid-driven framework?

A hybrid-driven framework is a combination of any two other framework types. It can be a combination of data-driven and modular, or a combination of data-driven and keyword-driven. Any mix of two other frameworks is called a hybrid-driven framework. In this tutorial the hybrid-driven approach is the main focus, and the framework is designed and developed through defined phases rather than being built all at once on day one.

Q: What are the phases of designing and developing an automation framework?

The phases run in a set order. First, understand the requirements thoroughly, including what URLs, requests, and responses are involved, using functional specifications and Swagger. Second, choose the right automation tool or library. Third, design the framework, deciding the folder structure and which files to create and how to manage them. Fourth, develop and implement those designed files. Finally, handle execution plus continuous integration (CI). You do not jump directly into development on day one.

Q: Why are REST Assured and Selenium called libraries instead of tools?

REST Assured and Selenium are libraries, not tools, even though many people call them tools. A tool is something you download, install, and use as a standalone application. In contrast, REST Assured and Selenium are third-party libraries that contain a number of JAR files bundled together with many classes and methods. You simply download them and use them inside your automation. Because they are bundled collections of classes and methods rather than installed standalone applications, they are technically libraries.

Q: How do you choose the right automation tool for API testing?

Choosing the right tool depends on many factors. These include the budget, the test team's skill set, and the technology used to design the APIs. Teams often perform an analysis comparing available market tools to find the one most suitable for their requirements. For API testing there are fewer tool options than for web automation, but you can use any of them, and most available API testing tools are open source. After considering these factors, the appropriate tool is selected.

Q: What documentation do you need before starting framework development?

Before starting the framework you need functional specifications and a Swagger document. Functional specifications are the starting documentation that gives a brief, high-level idea of the models, the kinds of requests, and the responses, and you use them to begin preparing test cases. Initially you may not have Swagger and you won't have URLs yet. Once developers provide the Swagger tool, you get full clarity on request formats, responses, URLs, and endpoints. Both are important references for framework development.

Q: Which API and model does the tutorial use to build the framework?

The tutorial automates the Petstore API, whose Swagger document lists multiple models including API Response, Category, Pet, Tag, Order, and User. These can be grouped into three main modules: Pet, Store, and User. The tutorial first takes the User model to demonstrate how to design and develop the framework from scratch. Manual test cases are prepared and reviewed first, before automation. After understanding the framework implementation with the User model, learners can automate the Store and Pet models on their own.

Summary & Key Takeaways

  • Every automation effort needs a framework to properly maintain the many files involved: different URLs and endpoints, payload classes per model, data-driven test cases, and reports. The main objective of designing a framework is reusability, so components built once can be executed or used multiple times across the automation.

  • Beyond reusability, a framework must deliver maintainability so another person can later add or modify existing test cases, and readability so anyone can easily read and understand the code. The tutorial focuses on a hybrid-driven framework, which combines any two framework types such as data-driven with modular or keyword-driven.

  • Framework development follows phases rather than jumping straight into coding: understand requirements via functional specs and Swagger, choose the right tool or library, design the folder structure and files, develop those files, then run execution with CI. Using the Petstore API, the tutorial prepares manual test cases and starts with the User model.


Read in Other Languages (beta)

Share This Summary 📚

Explore More Summaries from SDET- QA 📚