Run Tests

In shortHow to run your 10xGraph project's test suite using 10xgraph test. Covers coverage, thresholds, keyword filters, and 10xgraph.json configuration.

  • 3 min read
  • 10 sections
  • Updated
  • v0.9.2
  • Markdown

The 10xgraph test command is a thin wrapper around pytest. It runs from the project root, reads optional defaults from 10xgraph.json, and forwards any extra arguments to pytest directly.

Prerequisites

pytest must be installed in your environment:

Terminal
pip install pytest

For coverage reports, also install pytest-cov:

Terminal
pip install pytest-cov

Quick start

From the folder that contains 10xgraph.json:

Terminal
10xgraph test

No path is passed to pytest, so pytest uses its own discovery rules: it reads testpaths from pytest.ini or pyproject.toml, or falls back to scanning the current directory. This matches the behaviour of running pytest directly.

Target a specific path

Provide a path to restrict the run to a directory or file:

Terminal
# A subdirectory
10xgraph test tests/unit

# A single file
10xgraph test tests/unit/test_graph.py

When a path is given, pytest only collects tests under that path.

Run with coverage

Terminal
10xgraph test --coverage

This adds the following flags to pytest:

plaintext
--cov=. --cov-report=term-missing --cov-report=html:htmlcov

A summary is printed in the terminal and a full HTML report is written to htmlcov/index.html.

Open the HTML report automatically

Terminal
10xgraph test --coverage --html

After the test run completes, the HTML coverage report opens in your default browser.

Filter tests by keyword

Terminal
10xgraph test -k "weather"

The -k expression is forwarded directly to pytest. Only tests whose name or node ID matches the expression are collected and run.

Pass raw pytest arguments

Use -- to separate 10xgraph test options from raw pytest arguments:

Terminal
# Short output, show only failures
10xgraph test -- -q --tb=short

# Combine with coverage
10xgraph test --coverage -- --tb=long --no-header

Everything after -- is appended verbatim to the pytest command.

Configure defaults in 10xgraph.json

Add a test section to 10xgraph.json to set project-level defaults. All fields are optional. CLI flags always take precedence over config values.

JSON
{
  "agent": "graph.react:app",
  "test": {
    "path": "tests",
    "coverage": true,
    "coverage_threshold": 80
  }
}
Field Description
path Default test path when no PATH argument is given
coverage Enable coverage on every run without needing --coverage
coverage_threshold Minimum coverage percentage; the run fails if coverage drops below this value

With this config, a bare 10xgraph test is equivalent to:

Terminal
10xgraph test tests --coverage -- --cov-fail-under=80

Enforce a coverage threshold in CI

Set coverage_threshold in 10xgraph.json and run 10xgraph test in CI. If coverage falls below the threshold, pytest exits with a non-zero code and the CI step fails.

YAML
# .github/workflows/ci.yml (example)
- name: Run tests
  run: 10xgraph test --coverage

No extra flags needed in the workflow, the threshold is already declared in the config file.

Verbose and quiet modes

Terminal
# Extra pytest output
10xgraph test --verbose

# Suppress everything except errors
10xgraph test --quiet

Common scenarios

Run a fast smoke test against one file:

Terminal
10xgraph test tests/test_smoke.py -k "health"

Full coverage check during local development:

Terminal
10xgraph test --coverage --html

Strict CI run with threshold:

JSON
{
  "test": {
    "coverage": true,
    "coverage_threshold": 70
  }
}
Terminal
10xgraph test

Pass pytest markers:

Terminal
10xgraph test -- -m "not integration"

Common issues

“No module named pytest”

  • Install pytest: pip install pytest

“No module named pytest_cov”

  • Install pytest-cov: pip install pytest-cov

Coverage is below threshold, run fails

  • The exit code reflects the threshold failure. Increase test coverage or lower coverage_threshold in 10xgraph.json.

Tests directory not found

  • Pass the correct path explicitly: 10xgraph test src/tests
  • Or update "path" in the test section of 10xgraph.json
Last updated for v0.9.2Edit this page on GitHubReport an issue