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

  1. Run the module – Create a run configuration that executes python -m cstesting with working directory set to your project and optional parameters (file path or glob).
  2. Debug – Use the same configuration in debug mode and set breakpoints in your it bodies or in cstesting sources.

Debugging tips

  1. Headed modecreate_browser(headless=False) so you can watch the browser.
  2. Slow downawait browser.sleep(2000) or await browser.sleep({"timeout": 2000}) before a failing step (see browser.py).
  3. Assertions – Use from cstesting import expect on values from await browser...; there is no browser.assertThat. See Assertions.
  4. HTML report – After a run, check report/report.html (README.md).
  5. Console / network – In headed mode, use Chromium DevTools on the automation window.

Summary

TopicPython CSTesting
Default discoverypython -m cstesting uses **/*.test.py under the current directory.
Single file / folderpython -m cstesting path/to/file.py or tests/
ProgrammaticImport the test module (registers suites), then from cstesting import run; result = run()
Headless (browser tests)create_browser(headless=True) (default)
Headedcreate_browser(headless=False) or config CLI --headed
From IDERun/debug python -m cstesting with arguments