Skip to content

Repository files navigation

Test Prioritization Engine

CI Pipeline TypeScript Node.js Docker Jest License: MIT

Test prioritization engine - ranks tests by execution priority using risk signals (code churn, failure history, change proximity, business criticality) to run the most valuable tests first within time budgets.

Features

  • Multi-Signal Risk Scoring - Combine code churn, failure history, change coverage, and criticality
  • Priority Ranking - Sort tests highest-to-lowest value for execution order
  • Time Budget Selection - Given N minutes, select the highest-value tests that fit
  • Code Churn Analysis - Files changed frequently produce higher-priority tests
  • Failure History - Recently failed tests get promoted in execution order
  • Business Criticality - Tag tests by feature importance (critical > high > medium > low)
  • Configurable Weights - Tune signal importance per team or project
  • Execution Plan Output - Ordered file path list ready for any test runner

How It Works

Test Metadata + Changed Files + Churn Map
              |
              v
    [Risk Signal Calculator]
    - Code churn (0-1)
    - Recent failure (0-1)
    - Change coverage (0-1)
    - Criticality (0-1)
              |
              v
    [Weighted Score: 0-100]
              |
              v
    [Priority Ranker] --> Sorted test list
              |
              v
    [Budget Selector] --> Tests that fit in N minutes

Risk Signals

Signal Weight Description
Recent Failure 35% Tests that failed recently are more likely to catch regressions
Change Coverage 25% Tests covering currently changed code are directly relevant
Code Churn 20% Frequently modified code is more likely to contain bugs
Business Criticality 20% Payment tests matter more than tooltip tests

Example

Given 50 tests and a 5-minute CI budget:

Total tests: 50 (would take 18 minutes)
Budget: 5 minutes
Selected: 14 highest-priority tests
Coverage: 28% of tests, but 85% of risk

The 14 selected tests cover the most recently changed, most failure-prone, most critical paths first.

Project Structure

test-prioritization-engine/
+-- src/
|   +-- config/        # Configuration, logger, defaults
|   +-- scoring/       # Risk signal calculation + priority scoring
|   +-- prioritizer/   # Ranking + time budget selection
|   +-- engine/        # Full orchestration pipeline
|   +-- api/           # Express REST server
|   +-- index.ts       # CLI entry point
+-- tests/unit/        # Unit tests (20+ tests)
+-- .github/workflows/ # CI pipeline
+-- Dockerfile         # Multi-stage Docker build
+-- docker-compose.yml
+-- package.json
+-- tsconfig.json
+-- README.md
+-- LICENSE

Getting Started

Prerequisites

  • Node.js >= 20.0.0
  • Docker (optional)

Installation

git clone https://github.com/Djones-qa/test-prioritization-engine.git
cd test-prioritization-engine
npm install
cp .env.example .env
npm run dev

Running Tests

npm test              # All tests
npm run test:unit     # Unit tests only
npm run test:coverage # With coverage
npm run lint          # ESLint

Configuration

Variable Default Description
PORT 3011 Server port
NODE_ENV development Environment
LOG_LEVEL info Winston log level
WEIGHT_CHURN 0.2 Code churn signal weight
WEIGHT_FAILURE 0.35 Recent failure signal weight
WEIGHT_COVERAGE 0.25 Change coverage signal weight
WEIGHT_CRITICALITY 0.2 Business criticality weight

API Endpoints

Method Endpoint Description
GET /api/health Service health check

CI/CD Pipeline

  1. Lint & Type Check - ESLint + TypeScript compiler
  2. Unit Tests - Jest with coverage
  3. Docker Build - Multi-stage production image

Author

Darrius Jones

License

MIT - 2026 Darrius Jones

See LICENSE for details.

About

Test prioritization engine - ranks tests by failure probability, recency, code proximity, execution cost. Faster CI feedback by running likely-to-fail tests first. TypeScript/Node.js + Docker + GitHub Actions CI.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages