Running and debugging tests
Introduction
CSTesting for Python (C:\CSTesting-Python) discovers files named *.test.py or *.spec.py (or you pass a path to a single file). Each file is imported so your describe / it calls register suites; then python -m cstesting runs them via cstesting.runner.run. The CLI is implemented in cstesting/cli.py.
For Playwright tests you choose headless vs headed in create_browser(headless=...) in your own before_all or test code. Config-driven runs (python -m cstesting run login.conf or a .conf path) support --headed on the CLI.
Running from the CLI
From your project root (with cstesting installed):
python -m cstesting
python -m cstesting example/math_test.py
python -m cstesting tests/
python -m cstesting "**/*.test.py"
Filter by tags (see docs/CLI.md in the Python repo):
python -m cstesting --tag smoke tests/
python -m cstesting -t smoke,regression "**/*.test.py"
Pause after a failure when stdin is a TTY:
python -m cstesting tests/ --pause-on-failure
See Lifecycle & hooks for describe, it, and hooks.
Headed browser (Playwright)
For code-first tests, pass headless=False to create_browser:
browser = asyncio.get_event_loop().run_until_complete(
create_browser(headless=False)
)
For config files, use python -m cstesting run my.conf --headed or put headed=true in the .conf file (README.md).
Running from the IDE
- Run the module – Create a run configuration that executes
python -m cstestingwith working directory set to your project and optional parameters (file path or glob). - Debug – Use the same configuration in debug mode and set breakpoints in your
itbodies or incstestingsources.
Debugging tips
- Headed mode –
create_browser(headless=False)so you can watch the browser. - Slow down –
await browser.sleep(2000)orawait browser.sleep({"timeout": 2000})before a failing step (seebrowser.py). - Assertions – Use
from cstesting import expecton values fromawait browser...; there is nobrowser.assertThat. See Assertions. - HTML report – After a run, check
report/report.html(README.md). - Console / network – In headed mode, use Chromium DevTools on the automation window.
Summary
| Topic | Python CSTesting |
|---|---|
| Default discovery | python -m cstesting uses **/*.test.py under the current directory. |
| Single file / folder | python -m cstesting path/to/file.py or tests/ |
| Programmatic | Import the test module (registers suites), then from cstesting import run; result = run() |
| Headless (browser tests) | create_browser(headless=True) (default) |
| Headed | create_browser(headless=False) or config CLI --headed |
| From IDE | Run/debug python -m cstesting with arguments |