Skip to main content

QATLibrary

gh ci gh tests PyPI version Maintenance License: MIT

QAT (Quick API Tests) Library is a Data/Configuration Driven REST API Test Automation Library. Can be used as a Robot Framework Library or as standalone tool (CLI). This tool does not solve complex REST API automation scenarios, rather, provides a simple, lightweight and data-driven approach to create automated REST API tests quickly. For complex flows, it is recommended to use the library with Robot Framework.

Features

  • No coding required. Quick and easy implementation for REST API Tests.
  • Initialize sample config and Test Data with a single command.
  • Run from CLI (CI/CD friendly).
  • Store Test Data, Documentation and Assertions in CSV File.
  • Authorization: Basic, Digest, OAuth1
  • Run as a Robot Framework Library with Dynamic Test Generation Support.
  • Supports all HTTP Methods, SSL Certificates, Proxy Server, Stream, Redirection, Request Timeout etc.
  • Robot Framework based execution, reports and logs (CLI or Library).

Built-in Assertions

  • Status Code
  • JSON Schema
  • Response Body
  • Response Headers
  • Response Time/SLA
  • Server Certificate

Install QATLibrary

QATLibrary is available in PyPI. You can install using Pip:

pip install qatlibrary

Execution

Getting started from scratch is only a few commands away. Follow -

  1. Generate Sample Test Data CSV and Config YAML from CLI run (Skip this step if you already have Test Data and Config files):

    qat init
    
  2. Execute Tests Using CLI (standalone):

    qat run -c config.yaml -f TestCases.csv
    
  3. Delete report files (*.html and *.xml) in current directory:

    qat clean
    

    or to clean a specific report directory:

    qat clean -d path/to/dir
    
  4. For CLI Help (shows all required and optional args, usage etc):

    qat --help
    

Use as Robot Framework Library

Example:

*** Settings ***
Library          QATLibrary
Suite Setup      QAT Dynamic Tests Setup        csvFile=${csvData}
Variables        config.yaml        # Or can be a robot framework variable (Test/Suite/Variablefile etc.)

*** Variables ***
${host}          httpbin.org
${csvData}       Tests.csv

*** Test Cases ***
Place Holder Test
    [Documentation]  Placeholder Test Required by Robot Framework Suite Runner.  
    No Operaiton 

Configurations and Test Data

QATLibrary requires a CSV file with required data to drive the tests. Config yaml or .py files can inject your desired configurations during execution.

Generating Sample Test Data CSV and Config YAML is easy. Simply run:

qat init

This command should generate two sample files like below -

  1. Sample CSV Test Data: Test Cases or Data file. Test cases gets generated based on this file's content using Robot Framework.

  2. Sample Config YAML: This file contains various runtime configurations for tests. Can be utilize to accommodate various CI or Test environments. Please follow the inline comments for more details -

    ---
    # optional args; uncomment as-needed. 
    # Any block or k/v not required, recommended to keep commented out for reasonable defaults. 
    base_url: httpbin.org           # base url/server name. Default localhost
    timeout: 10                     # In seconds. Default 5 seconds
    allow_redirects: True           # Allow Redirects. Default True.
    stream: False                   # True/False. Default False.
    
    ## global headers - these are added to every request from your data csv. All headers should be strings.
    headers:
      user-agent: QATLibrary                                  # this is a static header
      Authorization: Basic c29tZXVzZXI6bm90dmVyeXNlY3JldHBhc3M=
      # dynamic headers can be added with ${{ }} syntax like below -
      X-correlation-id: ${{str(__import__('uuid').uuid4())}}         # dynamic headers use python's eval func.
      random-digit: ${{str(__import__('random').randint(0,99))}}     # dynamic headers use python's eval func.
    
    
    ## To enable proxies for http/https, enable the following config.
    #proxies:
    #  http_proxy:                   # HTTP proxy. Default None.
    #  https_proxy:                  # HTTPS proxy. Default None.
    #  no_proxy:                     # Bypass proxy
    
    ## SSL/TLS configuration for REST API calls. Enable to configure.
    #tls:
    #  verify_server_cert: True      # True/False or path to CA Bundle. Default False.
    #  certificate:                  # .pem format certificate. Default None
    #  private_key:                  # .pem format private key (unencrypted). Default None.
    
    ## Note that the specific details of how to obtain an access token may vary depending on the authentication scheme and API provider.
    ## Be sure to check the API documentation for instructions on how to obtain an access token for your use case.
    ## bearer auth / access token config. Enable below configs if required.
    
    #bearer_auth:
    #  token_url:                                # token_url for bearer auth
    #  payload:                                  # generic payload. supports all direct key/value. below are the common ones.
    #    client_id:
    #    client_secret:
    #    scope:
    #    grant_type:
    
    ## Enable following block for bearer auth TLS config.
    #  tls:
    #    verify_server_cert: True       # True/False or path to CA Bundle. Default False.
    #    certificate:                  # .pem format certificate. Default None
    #    private_key:                  # .pem format private key (unencrypted). Default None
    

Once the files are generated, you can rename them according to your test suites or requirements.

Contributing

This is Sharif. I started this project basically to make my life a bit easier around simple REST API tests. This project is ideal for you if want to get some automated tests done quickly for your projects without coding and powerful assertion methods out of the box.

QATLibrary is on GitHub. Get in touch, via GitHub or otherwise, if you've got something to contribute, it'd be most welcome! Please follow the CONTRIBUTING.md for detailed guidelines.

License

QATLibrary is open source software provided under the MIT License. Please follow LICENSE.md for more details.

Release files for QATLibrary 23.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for QATLibrary 23.5.3
File Size Uploaded
QATLibrary-23.5.3.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for QATLibrary 23.5.3
File Interpreter ABI Platform
QATLibrary-23.5.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 30.2 kB

Release files / QATLibrary-23.5.3.tar.gz

Download URL QATLibrary-23.5.3.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0b698a854e9d34709381d24589ae60b9cbb7c65715dd948a0a11154df3280c13
BLAKE2b-256 checksum
How to use checksums
cb942842986b27c70c166a8c361bbe310107a110f4c3c4cd89636d4c8f0c2492
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / QATLibrary-23.5.3-py2.py3-none-any.whl

Download URL QATLibrary-23.5.3-py2.py3-none-any.whl
Size 15.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
a75008df505fbad336397dfc32aee7747650e416a57f8bd4997efa10cb55ab42
BLAKE2b-256 checksum
How to use checksums
75c74d28598a7965e2c40f39254ee4d4f8cf18f227041c60b83af42bf92eac73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

23.5.3 This release

2 release files

23.5.2

2 release files

23.4.1

2 release files

21.5.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page