Metadata-Version: 2.4
Name: flaktor
Version: 0.1.0
Summary: Framework-agnostic flaky test intelligence tool - Track, analyze, and fix flaky tests
Author-email: Panjatan Labs <panjatan.tech@gmail.com>
License: MIT License
        
        Copyright (c) 2026 PanjatanCoders
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/PanjatanCoders/flaktor
Project-URL: Repository, https://github.com/PanjatanCoders/flaktor
Project-URL: Issues, https://github.com/PanjatanCoders/flaktor/issues
Keywords: testing,flaky-tests,qa,ci-cd,junit,cucumber,playwright
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Environment :: Console
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: typer>=0.9.0
Requires-Dist: rich>=13.0.0
Requires-Dist: lxml>=4.9.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Provides-Extra: mcp
Requires-Dist: mcp>=2.0.0; extra == "mcp"
Dynamic: license-file

# Flaktor

**Flaky test detection made simple.**

Flaktor is a framework-agnostic CLI tool that tracks your test results over time and identifies flaky tests - tests that sometimes pass and sometimes fail without code changes.

## Features

- **Framework Agnostic**: Works with any test framework that outputs JUnit/xUnit XML
- **Simple CLI**: Easy-to-use commands for uploading results and viewing reports
- **Flaky Detection**: Automatically detects tests with inconsistent results
- **CI/CD Ready**: Built-in support for GitHub Actions, GitLab CI, and more
- **Beautiful Output**: Rich terminal output with tables and colored status
- **Lightweight**: SQLite database with no external dependencies

## Installation

```bash
pip install flaktor
```

## Quick Start

```bash
# Initialize the database
flaktor init

# Run your tests with JUnit XML output
pytest --junitxml=results.xml tests/

# Upload results
flaktor upload results.xml

# View flaky tests
flaktor list --flaky

# Generate a report
flaktor report
```

## Commands

| Command | Description |
|---------|-------------|
| `flaktor init` | Initialize the database |
| `flaktor upload <files>` | Upload test results from XML files |
| `flaktor list` | List tests with statistics |
| `flaktor list --flaky` | Show only flaky tests |
| `flaktor history <test>` | View detailed history for a test |
| `flaktor report` | Generate a test health report |
| `flaktor clean` | Remove old data from the database |
| `flaktor info` | Show database information |
| `flaktor mcp` | Start the MCP server for AI coding agents |

## CI/CD Integration

Flaktor is designed for CI/CD pipelines. Track test results across runs to detect flaky tests.

### GitHub Actions

```yaml
- name: Upload to Flaktor
  run: |
    flaktor upload results.xml \
      --branch "${{ github.ref_name }}" \
      --commit "${{ github.sha }}"
```

### GitLab CI

```yaml
script:
  - flaktor upload results.xml --branch "$CI_COMMIT_REF_NAME" --commit "$CI_COMMIT_SHA"
```

See [docs/ci-cd-integration.md](docs/ci-cd-integration.md) for complete examples for:
- GitHub Actions
- GitLab CI/CD
- Jenkins
- CircleCI
- Azure DevOps

## MCP Server (for AI coding agents)

Flaktor can expose its flaky-test data to AI coding agents (Claude Code, Cursor, etc.) over the [Model Context Protocol](https://modelcontextprotocol.io), so an agent can check whether a failing test is a known flake *before* debugging it as a real bug. The server is read-only — `upload`, `init`, and `clean` stay CLI-only.

```bash
pip install "flaktor[mcp]"
```

Add it to your MCP client config, e.g. for Claude Code:

```bash
claude mcp add flaktor -- flaktor mcp
```

Available tools: `list_flaky_tests`, `check_test_flakiness`, `get_test_history`, `get_test_summary`, `get_database_stats`.

## Understanding Flakiness

Flaktor calculates a "flip rate" for each test:

```
flip_rate = 2 * min(pass_rate, fail_rate)
```

- A test that always passes: flip_rate = 0%
- A test that always fails: flip_rate = 0%
- A test that passes 50% of the time: flip_rate = 100% (most flaky)
- A test that passes 80% of the time: flip_rate = 40%

Tests with a flip rate above 20% (default threshold) are considered flaky.

## Example Output

```
$ flaktor list --flaky

                    Flaky Tests (last 30 days)
+----------------------------------------+------+------+------+-----+--------+
| Test Name                              | Flip | Pass | Runs | P/F | Avg    |
+----------------------------------------+------+------+------+-----+--------+
| test_api.TestAuth.test_token_refresh   | 80%  | 60%  | 25   | 15/10 | 0.45s |
| test_db.TestConn.test_reconnect        | 60%  | 70%  | 20   | 14/6  | 1.23s |
| test_ui.TestLogin.test_remember_me     | 40%  | 80%  | 15   | 12/3  | 2.10s |
+----------------------------------------+------+------+------+-----+--------+
```

## Development

```bash
# Clone the repository
git clone https://github.com/PanjatanCoders/flaktor.git
cd flaktor

# Install in development mode
pip install -e .

# Run tests
pytest tests/ -v
```

## License

MIT License - see LICENSE file for details.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.
