TestQL — Interface Query Language for GUI/API/encoder testing
Project description
TestQL — Interface Query Language for Testing
AI Cost Tracking
- 🤖 LLM usage: $0.4500 (3 commits)
- 👤 Human dev: ~$400 (4.0h @ $100/h, 30min dedup)
Generated on 2026-04-15 using openrouter/qwen/qwen3-coder-next
TestQL is a declarative DSL (Domain Specific Language) for testing GUI, REST API, and hardware encoder interfaces. It provides a simple, readable syntax for writing automated tests without programming overhead.
Installation
# Install from source
pip install -e .
# Install with development dependencies
pip install -e ".[dev]"
Requirements
- Python 3.10+
- HTTPX for API testing
- Playwright for GUI testing (optional)
Quick Start
# Run a test scenario
testql scenarios/tests/test-api.tql --url http://localhost:8101
# Dry-run (parse + validate only)
testql scenarios/views/connect-id-barcode.tql --dry-run
# JSON output for CI integration
testql scenarios/tests/test-api.tql --output json
# Run with verbose logging
testql scenarios/tests/test-api.tql --verbose
Language Reference
Variables
SET api_url "http://localhost:8101"
SET timeout 5000
GET api_url # Prints variable value
Variables support ${var} and $var interpolation:
SET base_url "http://localhost:8101"
API GET "${base_url}/api/devices"
Logging
LOG "Starting test suite"
LOG "Current value: ${var}"
API Commands
# HTTP methods
API GET "/api/v3/data/devices"
API POST "/api/v3/scenarios" {"id": "ts1", "name": "Test"}
API PUT "/api/v3/devices/123" {"status": "active"}
API DELETE "/api/v3/scenarios/old"
Assertions
# Status code assertions
ASSERT_STATUS 200
ASSERT_OK # Shorthand for 2xx status
# Content assertions
ASSERT_CONTAINS "device"
ASSERT_CONTAINS "status": "ok"
# JSON path assertions
ASSERT_JSON data.length > 0
ASSERT_JSON devices[0].id == "dev-001"
ASSERT_JSON status != "error"
Operators: ==, !=, >, >=, <, <=
GUI Navigation (Playwright)
# Navigation
NAVIGATE "/connect-workshop"
NAVIGATE "${base_url}/devices"
# Interaction
WAIT 500
CLICK "[data-action='search']"
INPUT "#search-input" "drager"
CLICK "button[type='submit']"
# Assertions
ASSERT_VISIBLE "[data-testid='results']"
ASSERT_TEXT "#status" "Connected"
Hardware Encoder Commands
ENCODER_ON # Activate encoder mode
ENCODER_FOCUS column1 # Focus specific column
ENCODER_SCROLL 3 # Scroll 3 steps
ENCODER_CLICK # Confirm (single click)
ENCODER_DBLCLICK # Cancel (double click)
ENCODER_PAGE_NEXT # Next page
ENCODER_PAGE_PREV # Previous page
ENCODER_STATUS # Print current encoder state
ENCODER_OFF # Deactivate encoder mode
Script Composition
# Include common setup
INCLUDE "common-setup.tql"
# Include relative paths
INCLUDE "../helpers/auth.tql"
Control Flow (Planned)
IF status == "ready"
LOG "System ready"
ELSE ERROR "System not ready"
LABEL start
REPEAT 3 {
API GET "/api/ping"
}
GOTO start
Project Structure
testql/
├── testql/
│ ├── cli.py # Command-line interface
│ ├── base.py # Base test runner
│ ├── commands/ # Command implementations
│ ├── runners/ # Test execution runners
│ └── reporters/ # Output formatters
├── scenarios/ # Sample test scenarios
│ ├── tests/ # Automated test suites
│ ├── views/ # GUI view tests
│ ├── diagnostics/ # System diagnostic scripts
│ ├── examples/ # Usage examples
│ └── recordings/ # Recorded test sessions
├── docs/
│ ├── testql-spec.md # Full language specification
│ └── recipes/ # Common testing patterns
└── tests/ # Unit tests
Scenario Organization
TestQL scenarios are .tql files organized by category:
| Directory | Purpose | Example |
|---|---|---|
scenarios/tests/ |
API/integration tests | test-api.tql |
scenarios/views/ |
GUI view tests | connect-id-barcode.tql |
scenarios/diagnostics/ |
System checks | health-check.tql |
scenarios/examples/ |
Learning samples | hello-world.tql |
scenarios/recordings/ |
Recorded sessions | user-flow-1.tql |
CLI Options
testql <file> [options]
Options:
--url <url> Base URL for API tests (default: http://localhost:8101)
--dry-run Parse and validate only, don't execute
--output <format> Output format: text (default), json, junit
--verbose Enable verbose logging
--timeout <ms> Default timeout for operations
Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=testql
# Run specific test file
pytest tests/test_runner.py -v
Example Scenario
# scenarios/tests/test-api.tql
SET base_url "http://localhost:8101"
LOG "Testing device API"
# Test GET endpoint
API GET "${base_url}/api/v3/data/devices"
ASSERT_OK
ASSERT_JSON data.length > 0
# Test POST endpoint
API POST "${base_url}/api/v3/scenarios" {"name": "Test Scenario"}
ASSERT_STATUS 201
ASSERT_JSON data.id != null
LOG "All tests passed!"
Documentation
- TestQL Specification — Complete language reference
- Recipes — Common testing patterns and examples
License
Licensed under Apache-2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file testql-0.1.1.tar.gz.
File metadata
- Download URL: testql-0.1.1.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f58d4cad47cbf4b1e81ae6501dcae6fb28ac1dff578780ea682831bbfa0cc684
|
|
| MD5 |
c419df936fc4b74162e820e4a78fb665
|
|
| BLAKE2b-256 |
ecc48d85e1aed35ab62b2ef83984039cf61f047af80589bcc962824c4ec440a9
|
File details
Details for the file testql-0.1.1-py3-none-any.whl.
File metadata
- Download URL: testql-0.1.1-py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e673887b36a706c321756490e2c937e3bd8a35e6cb932570f2ded42e47b07b6
|
|
| MD5 |
138a025c4d25bd80049d9d49873d6aa2
|
|
| BLAKE2b-256 |
8f3aadda695679fd73a1c79327094b9e72a45341e0ef613cd76b6f73b5149b09
|