Skip to content
Skills Library
Programming · Analysis

test-deduplicator

/test-deduplicator

Analyzes test suites to identify redundant and duplicate test cases using coverage analysis, semantic similarity, and execution results. Use this skill when you need to reduce test suite size, identify redundant tests, optimize test execution time, analyze test coverage overlap, find tests with identical behavior, or improve test suite maintainability. Triggers when users ask to deduplicate tests, find redundant test cases, reduce test suite size, identify duplicate tests, or optimize test coverage.

Repository
Skills-4-SE ↗
Licence
Apache-2.0
Last repository change
21.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
6
Scripts
3
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 21.08.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 3 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/coverage_analyzer.py, scripts/deduplicator.py, scripts/semantic_analyzer.py

What it does and when to use it

Analyzes test suites to identify redundant and duplicate test cases using coverage analysis, semantic similarity, and execution results. Use this skill when you need to reduce test suite size, identify redundant tests, optimize test execution time, analyze test coverage overlap, find tests with identical behavior, or improve test suite maintainability. Triggers when users ask to deduplicate tests, find redundant test cases, reduce test suite size, identify duplicate tests, or optimize test coverage.

Original author description

Analyzes test suites to identify redundant and duplicate test cases using coverage analysis, semantic similarity, and execution results. Use this skill when you need to reduce test suite size, identify redundant tests, optimize test execution time, analyze test coverage overlap, find tests with identical behavior, or improve test suite maintainability. Triggers when users ask to deduplicate tests, find redundant test cases, reduce test suite size, identify duplicate tests, or optimize test coverage.

How it works

  1. Overview
  2. Workflow
  3. Analysis Types
  4. Configuration
  5. Common Use Cases
  6. Understanding Results
  7. Best Practices
  8. Limitations
  9. Resources
Original SKILL.md headings · 322 lines, 1,150 words
SKILL.md preview
---
name: test-deduplicator
description: Analyzes test suites to identify redundant and duplicate test cases using coverage analysis, semantic similarity, and execution results. Use this skill when you need to reduce test suite size, identify redundant tests, optimize test execution time, analyze test coverage overlap, find tests with identical behavior, or improve test suite maintainability. Triggers when users ask to deduplicate tests, find redundant test cases, reduce test suite size, identify duplicate tests, or optimize test coverage.
---

# Test Deduplicator

## Overview

This skill analyzes test suites to identify redundant or duplicate tests by examining code coverage, semantic similarity, and execution behavior. It groups equivalent tests, explains deduplication rationale, and recommends which tests can be safely removed while preserving overall test effectiveness.

## Workflow

### 1. Collect Test Coverage Data

First, gather coverage information for each test in the suite.

**For Python projects with pytest:**
```bash
# Run tests with coverage for each test individually
pytest --cov=src --cov-report=json tests/

# Or use the coverage analyzer script with pre-collected data
python scripts/coverage_analyzer.py coverage_data.json --output coverage_analysis.json
```

**Coverage data format:**
```json
{
  "test_module::test_function_1": {
    "coverage": {
      "src/module.py": [10, 11, 12, 15, 20],
      "src/utils.py": [5, 6, 7]
    }
  },
  "test_module::test_function_2": {
    "coverage": {
      "src/module.py": [10, 11, 12, 15, 20],
      "src/utils.py": [5, 6, 7]
    }
  }
}
```

### 2. Analyze Semantic Similarity

Parse test code to identify semantic similarities:

```bash
python scripts/semantic_analyzer.py tests/*.py --output semantic_analysis.json --threshold 0.7
```

This analyzes:
- Assertion patterns
- Function call sequences
- Code structure similarity
- Variable usage patterns

### 3. Generate Deduplication Recommendations

Combine coverage and semantic analysis to produce recommendations:

```bash
python scripts/deduplicator.py \
  --coverage coverage_analysis.json \
  --semantic semantic_analysis.json \
  --output recommendations.json \
  --threshold 0.8
```

### 4. Review Recommendations

Examine the generated recommendations:

```json
{
  "redundant_groups": [
    {
      "type": "identical_coverage",
      "tests": ["test_a", "test_b", "test_c"],
      "reason": "Tests have identical code coverage",
      "confidence": 1.0,
      "keep": "test_a",
      "remove": ["test_b", "test_c"],
      "rationale": "test_a has descriptive name, fast execution"
    }
  ],
  "removal_candidates": [...],
  "coverage_impact": {
    "coverage_preserved": true,
    "tests_removed": 15
  }
}
```

### 5. Apply Deduplication

After manual review, remove approved redundant tests and verify coverage is preserved.

## Analysis Types

### Coverage-Based Analysis

Identifies tests with overlapping or identical coverage patterns.

**Redundancy Types:**
- **Identical Coverage**: Tests covering exactly the same lines
- **Subsumption**: One test's coverage is a subset of another
- **High Overlap**: Tests with >80% coverage similarity

**Script:** `scripts/coverage_analyzer.py`

**Output:**
- Identical coverage groups
- Subsumed tests
- Coverage similarity matrix
- Unique coverage contributions

### Semantic Analysis

Identifies tests with similar code structure and assertions.

**Similarity Metrics:**
- Assertion similarity (40% weight)
- Function call similarity (30% weight)
- Source code similarity (30% weight)

**Script:** `scripts/semantic_analyzer.py`

**Output:**
- Tests with identical assertions
- Semantically similar test pairs
- Test pattern groups

### Integrated Analysis

Combines multiple signals for comprehensive recommendations.

**Redundancy Score:**
```
Redundancy = 0.5 × Coverage_Sim + 0.3 × Semantic_Sim + 0.2 × Execution_Sim
```

**Script:** `scripts/deduplicator.py`

**Output:**
- Prioritized removal recommendations
- Confidence scores
- Coverage impact analysis
- Rationale for each recommendation

## Configuration

Customize analysis using the configuration template:

```bash
cp assets/deduplication_config.json my_config.json
# Edit my_config.json
```

**Key Settings:**

**Thresholds:**
- `identical_coverage`: 1.0 (exact match)
- `highly_similar_coverage`: 0.9
- `semantic_similarity`: 0.7
- `overall_redundancy`: 0.8

**Prioritization Weights:**
- `unique_coverage_lines`: 10 (most important)
- `execution_speed_bonus`: 5
- `stability_bonus`: 3
- `name_clarity_bonus`: 2

**Safety Checks:**
- `preserve_coverage`: true (must maintain coverage)
- `require_manual_review`: true (human approval needed)
- `min_confidence_for_auto_removal`: 0.95

## Common Use Cases

### Use Case 1: Reduce Test Suite Size
```
User: "Our test suite has grown to 500 tests and takes too long to run. Find redundant tests."
→ Run coverage analysis on all tests
→ Run semantic analysis on test files
→ Generate deduplication recommendations
→ Review and remove redundant tests
→ Verify coverage is preserved
```

### Use Case 2: Identify Duplicate Tests After Merge
```
User: "We merged two branches and suspect there are duplicate tests now."
→ Analyze tests from both branches
→ Find tests with identical coverage and assertions
→ Recommend which duplicates to remove
→ Prioritize keeping tests with better names/documentation
```

### Use Case 3: Optimize CI/CD Pipeline
```
User: "Tests take 30 minutes in CI. Which tests can we safely remove?"
→ Analyze coverage overlap
→ Find subsumed tests (tests fully covered by others)
→ Calculate time savings from removal
→ Generate removal plan with coverage guarantee
```

### Use Case 4: Test Suite Refactoring
```
User: "Clean up our test suite and remove low-value tests."
→ Identify tests with zero unique coverage contribution
→ Find tests with identical assertions
→ Group semantically similar tests
→ Recommend merging or removing redundant tests
```

## Understanding Results

### Redundancy Types in Reports

**Identical Coverage (Confidence: 1.0)**
- Tests execute exactly the same code paths
- Safe to remove all but one
- Keep the test with the best name/documentation

**Subsumed Tests (Confidence: 0.95)**
- One test's coverage is completely contained in another
- The subsumed test adds no unique value
- Safe to remove

**Highly Similar (Confidence: 0.85)**
- Tests have >80% redundancy score
- Review manually before removal
- Consider merging instead of removing

**Semantically Identical (Confidence: 0.90)**
- Tests have identical assertions and logic
- Different only in variable names or formatting
- Safe to remove duplicates

### Prioritization Rationale

Tests are prioritized to keep based on:

1. **Unique Coverage**: Tests covering lines no other test covers
2. **Execution Speed**: Faster tests preferred
3. **Stability**: Tests that consistently pass
4. **Descriptiveness**: Clear, well-named tests
5. **Recency**: Recently updated tests

## Best Practices

1. **Start Conservative**: Use high thresholds (≥0.9) initially

2. **Preserve Coverage**: Always verify total coverage remains unchanged

3. **Manual Review**: Review recommendations before removing tests

4. **Incremental Removal**: Remove tests in small batches, verify after each

5. **Consider Test Intent**: Don't remove tests that document important edge cases

6. **Monitor Impact**: Track test suite effectiveness after deduplication

## Limitations

1. **Parameterized Tests**: May appear similar but test different values

2. **Test Intent**: Cannot detect if tests serve different documentation purposes

3. **Flaky Tests**: Inconsistent coverage may affect analysis

4. **Integration Tests**: May intentionally duplicate unit test coverage

5. **Language Support**: Currently optimized for Python (extensible to other languages)

## Resources

### scripts/coverage_analyzer.py
Analyzes test coverage to identify redundant tests:
- Loads coverage data for each test
- Calculates coverage similarity (Jaccard index)
- Finds identical coverage groups
- Identifies subsumed tests
- Calculates unique coverage contributions

### scripts/semantic_analyzer.py
Analyzes test code for semantic similarity:
- Parses test files using AST
- Extracts assertions and function calls
- Calculates assertion similarity
- Compares code structure
- Identifies semantically identical tests

### scripts/deduplicator.py
Integrated deduplication engine:
- Combines coverage and semantic analysis
- Calculates composite redundancy scores
- Prioritizes tests to keep
- Generates actionable recommendations
- Validates coverage preservation

### references/deduplication_methodology.md
Comprehensive methodology guide covering:
- Redundancy types and detection methods
- Similarity metrics and formulas
- Deduplication strategies
- Prioritization algorithms
- Best practices and pitfalls
- Coverage impact analysis
- False positive mitigation

Read this reference when you need deeper understanding of the methodology, want to customize similarity metrics, or need to explain the approach to stakeholders.

### assets/deduplication_config.json
Configuration template for customizing:
- Analysis thresholds
- Prioritization weights
- Filtering rules
- Safety checks
- Output formats

Copy and modify this template to create custom configurations for specific projects or test suite characteristics.
Files in this package (6)
  • SKILL.md 9 KB
  • assets/deduplication_config.json 2 KB
  • references/deduplication_methodology.md 8 KB
  • scripts/coverage_analyzer.py 10 KB
  • scripts/deduplicator.py 12 KB
  • scripts/semantic_analyzer.py 10 KB

Versions

The database has no other skills named test-deduplicator.

Database snapshot: 13.11.2026 · package version 6390c63a464e (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100mutation-test-suite-optimizer
    Optimize test suites using mutation testing to maximize mutation kill rate with minimal tests. Use when you need to reduce test suite size while maintaining quality, identify redundant tests, improve mutation coverage, or validate test effectiveness. The skill analyzes test…
  • 95test-suite-prioritizer
    Analyzes test suites and suggests optimal test execution order based on code change impact and project requirements. Use when optimizing CI/CD pipelines, deciding which tests to run before committing, or selecting critical tests under time constraints. Prioritizes tests by…
  • 100generate-test-cases
    Use when the user asks to analyze code for test coverage, list what test cases are needed, or review testing strategy — WITHOUT generating actual test code.
  • 100api-test-suite-builder
    Use when the user asks to generate API tests, create integration test suites, test REST endpoints, or build contract tests.
  • 100test-evaluation
    Evaluate and debug existing test suites. TRIGGER when: reviewing or evaluating an existing test suite, debugging slow or flaky tests, assessing test coverage quality, or reviewing test code. DO NOT TRIGGER when: writing new tests (use test-conventions), or the task is purely…
  • 100evaluate-pester-test-development
    Evaluate Pester test quality — analyze code coverage gaps, check mock completeness, detect flaky tests, verify test isolation, measure execution time, generate coverage reports. Use when: evaluate tests, check coverage, find gaps, test quality, flaky tests, coverage report,…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.