Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Simple TestOps

Test management service for organizing test cases by features and stories, running test suites, and uploading JUnit XML results via CLI. Includes a web UI for browsing and managing everything.

Tech Stack

  • Web + API: Next.js (React) with App Router + API Route Handlers + SQLite (better-sqlite3)
  • CLI: TypeScript CLI (commander.js)
  • Monorepo: npm workspaces

Setup

npm install

Running

Start the app (port 3001):

cd packages/web
npm run dev

This serves both the web UI and the API at http://localhost:3001.

Seed Data

Populate the database with demo data:

cd packages/web
npm run seed

This creates a "Demo Project" with features, stories, and test cases.

API

All endpoints are under /api.

Projects

GET    /api/projects
POST   /api/projects          { "name": "My Project" }
GET    /api/projects/:id
PUT    /api/projects/:id      { "name": "New Name" }
DELETE /api/projects/:id

Features

GET    /api/features?project_id=1
POST   /api/features          { "project_id": 1, "name": "Auth" }
PUT    /api/features/:id      { "name": "New Name" }
DELETE /api/features/:id

Stories

GET    /api/stories?feature_id=1
POST   /api/stories           { "feature_id": 1, "name": "Login" }
PUT    /api/stories/:id       { "name": "New Name" }
DELETE /api/stories/:id

Test Cases

GET    /api/testcases?project_id=1
GET    /api/testcases?story_id=1
GET    /api/testcases/:id
GET    /api/testcases/:id/history
POST   /api/testcases         { "story_id": 1, "name": "test_login", "class_name": "tests.TestAuth", "key": "test_login" }
PUT    /api/testcases/:id     { "name": "...", "description": "...", "key": "..." }
DELETE /api/testcases/:id

Test Runs

GET    /api/runs?project_id=1
GET    /api/runs/:id
GET    /api/runs/:id/results
GET    /api/runs/:id/results?status=failed
GET    /api/runs/:id/coverage
DELETE /api/runs/:id

Upload Results

POST   /api/runs/upload       { "project_id": "demo", "xml": "<testsuite>...</testsuite>" }

Accepts JUnit XML content. The server parses the XML and automatically matches results to existing test cases using a 3-tier strategy: first by key (pytest function name), then by class_name + name, then auto-creates from classname parsing.

Run Coverage

GET    /api/runs/:id/coverage

Returns the full test spec for the project merged with results from this run. Every active test case is included — those without a result in the run have null status/id fields. Unmatched results (not linked to any test case) are also appended. Used by the run detail page to show test coverage gaps.

CLI

Build & Link

cd packages/cli
npm run build
npm link

This compiles the TypeScript source and makes the testops command available globally on your system.

Upload Results

# Single file
testops upload --project demo --file results.xml --url http://localhost:3001

# All XML files in a directory
testops upload --project demo --dir ./test-results --url http://localhost:3001

Test Mapping via Pytest Properties

TestOps maps test results to features, stories, and test cases. You can control this mapping by embedding properties in your JUnit XML output.

Supported Properties

Property Description Fallback
feature Feature name Derived from classname (second-to-last segment)
story Story name Derived from classname (last segment)
test_case Human-readable test case name Uses the function name from name attribute

When test_case is provided, the function name (XML name attribute) is stored as the matching key, and the property value becomes the display name.

Setup

  1. Define custom pytest markers in conftest.py:
import pytest

def pytest_configure(config):
    config.addinivalue_line("markers", "feature(name): assign test to a feature")
    config.addinivalue_line("markers", "story(name): assign test to a story")
    config.addinivalue_line("markers", "test_case(name): human-readable test case name")

@pytest.hookimpl(tryfirst=True)
def pytest_runtest_makereport(item, call):
    """Inject feature/story/test_case markers as JUnit XML properties."""
    if call.when == "call":
        for marker_name in ("feature", "story", "test_case"):
            marker = item.get_closest_marker(marker_name)
            if marker and marker.args:
                item.user_properties.append((marker_name, marker.args[0]))
  1. Annotate your tests — feature and story on the class, test_case on each method:
import pytest

@pytest.mark.feature("Authentication")
@pytest.mark.story("Login")
class TestLogin:
    @pytest.mark.test_case("Login with valid credentials")
    def test_login_valid_credentials(self):
        ...

    @pytest.mark.test_case("Login with invalid password")
    def test_login_invalid_password(self):
        ...

@pytest.mark.feature("Authentication")
@pytest.mark.story("Registration")
class TestRegister:
    @pytest.mark.test_case("Register a new user")
    def test_register_new_user(self):
        ...
  1. Run with JUnit XML output (use xunit1 so properties appear inside <testcase>):
pytest --junitxml=results.xml -o junit_family=xunit1

This produces <properties> elements inside each <testcase>:

<testcase classname="tests.test_auth.TestLogin" name="test_login_valid_credentials">
  <properties>
    <property name="feature" value="Authentication"/>
    <property name="story" value="Login"/>
    <property name="test_case" value="Login with valid credentials"/>
  </properties>
</testcase>

Fallback Behavior

When no feature/story properties are present, TestOps derives them from the classname attribute:

  • tests.test_auth.TestLogin → feature=test_auth, story=TestLogin
  • Last segment = story, second-to-last = feature

When no test_case property is present, the function name (name attribute) is used as both the display name and the key.

Typical Workflow

  1. Create a project via the API or web UI
  2. Define features, stories, and test cases (set key on each test case to match pytest function names)
  3. Run your tests with JUnit XML output (e.g. pytest --junitxml=results.xml)
  4. Upload results: testops upload --project <slug> --file results.xml --url http://localhost:3001
  5. Browse results at http://localhost:3001

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages