Skip to content

This repository is dedicated for API testing using robot framework.

narmathasankaran/api-test-using-robot-framework

Repository files navigation

api-test-using-robot-framework

Robot Framework API tests for httpbin and examples. This repository contains:

  • test cases in test/ using Robot Framework
  • a simple CI workflow in .github/workflows/ci.yaml that runs tests and uploads reports
  • a linter workflow in .github/workflows/linter.yaml that enforces formatting and lint rules

Deliverables

  • A Git repository containing the full project (this repo) — push to GitHub to enable CI.
  • This README with clear instructions for local setup, running tests, and viewing reports.

Prerequisites (local)

  • Python 3.10+ (3.12 recommended)
  • Docker (optional — only needed for the Docker-based runs or if you want to run httpbin in a container)
  • git

Set up the environment locally

  1. Clone the repository and change into it:
git clone <your-repo-url>
cd api-test-using-robot-framework
  1. Create and activate a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Install Python dependencies:
pip install --upgrade pip
pip install -r requirements.txt

Optional: if you prefer to use Docker to isolate the environment, see Dockerfile and scripts/run_ci_locally.sh.

Running tests locally

Run all Robot tests and generate HTML reports in the reports/ folder:

# ensure virtualenv is active
robot -d reports test/test_httpbin.robot

After the run you will have reports/log.html, reports/report.html, and reports/output.xml.

Viewing and sharing reports

  • Open reports/log.html or reports/report.html in a browser to inspect test output and failures locally.
  • In CI, the ci.yaml workflow uploads the reports folder as an artifact named robot-reports (retained for 7 days). Download it from the workflow run page.

Linting & formatting

There is a lint workflow (.github/workflows/linter.yaml) that runs on PRs and push to main and enforces:

  • Black (Python formatter) — run in --check mode in CI; locally you can auto-format with black .
  • Flake8 — static linting for Python
  • yamllint — YAML linting
  • JSON validation via python -m json.tool

Run linting locally:

# format code
black .
# run linters
flake8 .
yamllint .

If you want to enforce linting before merge, enable branch protection for main and add the Lint workflow as a required status check (Settings → Branches → Add rule).

Troubleshooting CI and httpbin availability

CI no longer depends on the public httpbin.org: the simple CI workflow starts a local httpbin service and tests point at it via HTTPBIN_URL=http://localhost:8080 to avoid public service 503s.

If a CI run still returns 503 or empty responses:

  • Check the workflow logs and look for the "Wait for httpbin readiness" step — it should confirm the local service is ready.
  • Add a quick debug step to the workflow to curl -v http://localhost:8080/get (I can add this if you'd like).

CI usage (quick)

From the GitHub UI: Actions → select Robot Tests CI - Simple → Run workflow.

From the CLI (GitHub CLI):

gh workflow run ci.yaml --ref main
gh run watch

Download artifacts after a run:

gh run list
gh run download <run-id> --name robot-reports --dir ./downloaded-reports

Reproducing CI locally (helper)

Use the bundled script to reproduce the CI steps locally (sets up venv, installs deps, runs tests, packages reports):

./scripts/run_ci_locally.sh

RabbitMQ / Messaging tests (optional)

This repo includes a simple RabbitMQ test that publishes and consumes a message using a local RabbitMQ server.

Start the services with Docker Compose (this will start httpbin and rabbitmq):

docker-compose up -d

Then run the RabbitMQ test locally (after the services are up):

robot -d reports test/test_rabbitmq.robot

To stop the services:

docker-compose down

Troubleshooting httpbin in Docker Compose

If httpbin container is marked unhealthy or fails to start, try the following:

  • Use the pinned kennethreitz/httpbin:0.9.2 image (already configured in docker-compose.yml).
  • Remove or relax custom healthchecks (some images do not include curl in the container).
  • Wait for the service to be ready before running tests (the robot-tests service includes a small wait loop).

GitHub Actions integration

This repository includes a GitHub Actions workflow at .github/workflows/ci.yaml that:

  • starts rabbitmq and httpbin as service containers for the job
  • installs Python dependencies from requirements.txt
  • runs the Robot Framework tests under test/ and writes results to reports/
  • uploads the reports directory as an artifact named robot-reports

To inspect artifacts after a CI run open the workflow run in the GitHub Actions UI and download the robot-reports artifact. You can reproduce the CI behavior locally with Docker Compose or the ./scripts/run_ci_locally.sh helper.

About

This repository is dedicated for API testing using robot framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published