API Testing Automation using UiPath

API (Full form Application Programming Interface) enables communication and data exchange between two separate software systems. A software system implementing an API contains functions/sub-routines which can be executed by another software system.

What is an API Testing:
  • API TESTING is a software testing type that validates Application Programming Interfaces (APIs).
The purpose of API Testing is to check the functionality, reliability, performance, and security of the programming interfaces.

  • In API Testing, instead of using standard user inputs(keyboard) and outputs, you use software to send calls to the API, get output, and note down the system's response.
  • API tests are very different from GUI Tests and won't concentrate on the look and feel of an application.
  • API mainly concentrates on the business logic layer of the software architecture.
Benefits of API Testing:

Earlier Testing :

  • With API testing, once the logic is designed, tests can be built to validate the correctness in responses and data.
  • We don't have to wait for various teams to finish their work or for full applications to be built - test cases are isolated and ready to build immediately.

Easier Test Maintenance :

  • UIs are constantly changing and moving around based on how they are accessed - browsers, devices, screen orientation, etc.
  • This creates a nightmare scenario where tests are being constantly rewritten to keep up with the actual code in production.
  • API changes are much more controlled and infrequent often times API definitions files like OpenAPI Spec can help make refactoring tests only seconds of work.

Faster Time To Resolution :

  • When API tests fail, we know exactly where our system broke and where the defect can be found. This helps reduce time triaging bugs between builds, integrations, and even different team-members.
  • The small, isolated footprint of an API test is perfect for faster MTTR stats, a valuable KPI for DevOps teams.

Speed and Coverage of Testing :

  • 300 UI tests may take 30 hours to run. 300 API tests could be run in 3 minutes. That means you’ll find more bugs in less time, while also being about to fix them immediately.

Types of API Testing in Brief

nit Testing :
  • A unit is the smallest functional part of the software. A unit is the one that may act on input and may have an output. So, unit testing is performed in the smallest module or method or function of the software.
    For example, We may choose to check whether a simple for loop is working as it should be.
  • While the testing world can be filled with misnomers, the easiest way to think about a unit test and APIs is testing a single endpoint, with a single request, looking for a single response or set of responses.
  • Many times, this type of testing can be done manually via the command line and something like a cURL command or with lightweight tools like SoapUI.
Integration Testing :
  • An integration testing means we test some modules or units together after integrating them.
  • Integration Testing is done only when the units involved in it, are tested individually with unit testing. This can be of further two types: (a) White Box testing. (b) Black Box testing.
  • Integration testing is the most often used form of API testing, as APIs are at the center of most integrations between internal or third-party services.
End-to-End Testing :
  • End-to-end testing is a technique that tests the entire software product from beginning to end to ensure the application flow behaves as expected.
  • It defines the product’s system dependencies and ensures all integrated pieces work together as expected.
  • The main purpose of End-to-end (E2E) testing is to test from the end user’s experience by simulating the real user scenario and validating the system under test and its components for integration and data integrity.
Performance Testing :
  • In performance testing, the run-time parameters of the software are checked.
  • This check is done mainly, to see how efficient the software is in the run time.
    For example, how many CPU cycles are being used for the execution of a certain module.
  • LoadUI Pro is a performance testing tool for RESTful, SOAP, and other web services that enable nearly any team member to embed performance tests into their CI/CD pipeline.

API Testing Tools

  • SoapUI is a headless functional testing tool dedicated to API testing, allowing users to test REST and SOAP APIs and Web Services easily.
  • Using SoapUI, users can get the full source and build the preferred features besides these abilities:

Characteristics of SoapUI

  • Create test quickly and easily with Drag and drop, Point-and-click
  • Quickly create custom code using Groovy
  • Powerful data-driven testing: Data loaded from files, and databases, and Excel so that they can simulate how consumers interact with the APIs
  • Create complex-scenarios & support asynchronous testing
Postman :
  • Being originally a Chrome browser plugin, Postman now extends its solution with the native version for both Mac and Windows.
  • Postman is a good choice for API testing for those who don’t want to deal with coding in an integrated development environment using the same language as the developers.

Characteristics of Postman :

  • Easy-to-use REST client
  • The rich interface which makes it easy to use
  • Can be used for both automated and exploratory testing
  • Can be run on Mac, Windows, Linux & Chrome Apps
  • Has a bunch of integrations like support for Swagger & RAML formats
  • Has Run, Test, Document and Monitoring Features
  • Doesn’t require learning a new language
  • Enable users to easily share the knowledge with the team as they can package up all the requests and expected responses, then send it to their colleagues.
Katalon Studio :
  • Katalon Studio is a free automation test tool to provide a common environment to create and execute UI functional, API/Web services and mobile testing.
  • The capability to combine UI and Business levels (API/Web services) for different environments (Windows, Mac OS, Linux) has been considered an advantage of Katalon Studio.
  • Katalon Studio supports SOAP and RESTful requests with various types of commands (GET, POST, PUT, DELETE) with parameterized capability.

Characteristics of Postman :

  • Support combination test between UI and API verification.
  • Support testing both SOAP and RESTful requests.
  • Hundreds of built-in keywords for creating test cases.
  • Support one of the most powerful assertion library, AssertJ to create fluent assertion with BDD style.
  • Support the data-driven approach.
  • It can be used for both automated and exploratory testing.
  • Suitable for both pros and non-techies
  • Apigee is a cross-cloud API testing tool, allowing users to measure and test API performance, supports and build API using other editors like Swagger.

Characteristics of Apigee :

  • It is multi-step and powered by Javascript
  • Allows the design monitor, deploy, and scale APIs
  • Identify performance issues by tracking API traffic, error rates, and response times
  • Easily create API proxies from the Open API Specification and deploy them in the cloud
  • Cloud, on-premise, or hybrid deployment model on a single code base
  • PCI, HIPAA, SOC2, and PII for apps and APIs
  • Apigee is purpose-built for digital business, and the data-rich mobile-driven APIs and apps that power it.
  • JMeter (open source) is widely used for functional API testing although it is actually created for load testing.

Characteristics of Apigee :

  • Supports replaying of test results
  • Automatically work with CSV files, allowing the team to quickly create unique parameter values for the API tests.
  • Users can include the API tests in CI pipelines thank the integration between JMeter and Jenkins
  • It can be used for both static as well as dynamic resources performance testing.

Rest-Assured is an open-source Java Domain-specific language that makes testing the REST service more simple.

Characteristics of Rest Assured :

  • Have a bunch of baked-in functionalities, which means users don’t have to code things from scratch.
  • Integrates seamlessly with the Serenity automation framework, so that users can combine the UI and REST tests all in one framework that generates awesome reports.
  • Support BDD Given/When/Then syntax
  • Users don’t necessarily need to be an HTTP expert
  • Assertible is an API testing tool that concentrates on automation and reliability.

Characteristics of Assertible :

  • Support for automating API tests through each step of a continuous integration and delivery pipeline.
  • Support for running API tests after deployments and integrates with familiar tools like GitHub, Slack, and Zapier.
  • Support validating HTTP responses with turn-key assertions such as JSON Schema validation and JSON Path data integrity checks
Karate DSL:
  • Karate DSL is a new API testing tool which helps create scenarios for API-based BDD tests in a simple way without writing step definitions.
  • Those definitions have been created by KarateDSL so that users can kickstart the API testing quickly.

Characteristics of Karate DSL :