Initial commit
This commit is contained in:
7
skills/mutation-test-runner/assets/README.md
Normal file
7
skills/mutation-test-runner/assets/README.md
Normal file
@@ -0,0 +1,7 @@
|
||||
# Assets
|
||||
|
||||
Bundled resources for mutation-test-runner skill
|
||||
|
||||
- [ ] mutation_report_template.md: Template for generating a detailed mutation test report with key metrics and findings.
|
||||
- [ ] example_mutation_results.json: Example JSON output from a mutation testing framework for demonstration purposes.
|
||||
- [ ] config_template.yaml: Template for configuring the mutation testing framework.
|
||||
76
skills/mutation-test-runner/assets/config_template.yaml
Normal file
76
skills/mutation-test-runner/assets/config_template.yaml
Normal file
@@ -0,0 +1,76 @@
|
||||
# Configuration template for the mutation-test-runner plugin
|
||||
|
||||
# General settings
|
||||
general:
|
||||
# Name of the project
|
||||
project_name: REPLACE_ME # e.g., 'my-awesome-project'
|
||||
|
||||
# Path to the project's source code
|
||||
source_path: src # Default source directory
|
||||
|
||||
# Path to the project's test suite
|
||||
test_path: tests # Default test directory
|
||||
|
||||
# Number of CPU cores to use for mutation testing. -1 means use all available cores.
|
||||
workers: -1
|
||||
|
||||
# Time limit (in seconds) for each test execution during mutation testing. Increase if your tests are slow.
|
||||
timeout: 60
|
||||
|
||||
# Mutation framework configuration
|
||||
framework:
|
||||
# Name of the mutation testing framework to use. Supported: stryker, pitest, mutmut, mutant
|
||||
name: stryker # Default framework
|
||||
|
||||
# Version of the mutation testing framework. Leave blank to use the latest.
|
||||
version: "" # Optional: Specify a version e.g., "3.0.0"
|
||||
|
||||
# Framework-specific configuration options. Consult the framework's documentation for available options.
|
||||
# Example for Stryker:
|
||||
options:
|
||||
mutate: # files or globs to mutate
|
||||
- 'src/**/*.js'
|
||||
- '!src/**/*.test.js'
|
||||
packageManager: 'npm' # npm, yarn, pnpm
|
||||
reporters: # reporters to use
|
||||
- 'html'
|
||||
- 'clear-text'
|
||||
|
||||
# Mutation operators to apply. Leave empty to use the framework's defaults.
|
||||
# Consult the framework's documentation for supported mutation operators.
|
||||
mutators:
|
||||
# List of mutators to apply. Examples: 'ArithmeticOperator', 'LogicalOperator', 'ConditionalExpression'
|
||||
# Example for PITest:
|
||||
- org.pitest.mutationtest.engine.gregor.mutators.ReturnValsMutator
|
||||
- org.pitest.mutationtest.engine.gregor.mutators.VoidMethodCallMutator
|
||||
|
||||
# Reporting configuration
|
||||
reporting:
|
||||
# Output format for the mutation testing results. Supported: html, json, csv, console
|
||||
format: html # Default output format
|
||||
|
||||
# Path to the output directory for the reports.
|
||||
output_path: reports # Default output directory
|
||||
|
||||
# Whether to generate a detailed report for each mutation. Can significantly increase the report size.
|
||||
detailed_report: false
|
||||
|
||||
# Advanced settings (optional)
|
||||
advanced:
|
||||
# List of files or directories to exclude from mutation testing.
|
||||
exclude:
|
||||
- node_modules
|
||||
- vendor
|
||||
|
||||
# Custom command to run the test suite. Overrides the default test command.
|
||||
test_command: npm test # Default test command
|
||||
|
||||
# Environment variables to set during test execution.
|
||||
environment:
|
||||
NODE_ENV: test # Example environment variable
|
||||
YOUR_VARIABLE: YOUR_VALUE_HERE
|
||||
|
||||
# Thresholds for mutation score
|
||||
thresholds:
|
||||
high: 80 # Percentage - High quality score
|
||||
low: 60 # Percentage - Low quality score, needs improvement
|
||||
155
skills/mutation-test-runner/assets/example_mutation_results.json
Normal file
155
skills/mutation-test-runner/assets/example_mutation_results.json
Normal file
@@ -0,0 +1,155 @@
|
||||
{
|
||||
"_comment": "Example mutation testing results JSON. Use this as a template for your own results.",
|
||||
"project": "example-project",
|
||||
"version": "1.0.0",
|
||||
"timestamp": "2024-01-26T10:00:00Z",
|
||||
"mutationScore": 85.71,
|
||||
"_comment": "Overall mutation score. Higher is better.",
|
||||
"summary": {
|
||||
"totalMutations": 21,
|
||||
"killed": 18,
|
||||
"survived": 3,
|
||||
"timeout": 0,
|
||||
"noCoverage": 0,
|
||||
"runtimeErrors": 0,
|
||||
"compileErrors": 0,
|
||||
"ignored": 0
|
||||
},
|
||||
"files": [
|
||||
{
|
||||
"path": "src/calculator.js",
|
||||
"_comment": "Relative path to the file.",
|
||||
"mutations": [
|
||||
{
|
||||
"id": 1,
|
||||
"location": {
|
||||
"start": {
|
||||
"line": 5,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 5,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"mutatorName": "ArithmeticOperator",
|
||||
"_comment": "Type of mutation applied.",
|
||||
"original": "+",
|
||||
"replacement": "-",
|
||||
"status": "Killed",
|
||||
"_comment": "Killed: Test caught the mutation. Survived: Mutation went undetected.",
|
||||
"killingTest": "test/calculator.test.js:test addition",
|
||||
"_comment": "Test that killed the mutation. Null if survived.",
|
||||
"description": "Replaced + with -",
|
||||
"static": false
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"location": {
|
||||
"start": {
|
||||
"line": 9,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 9,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"mutatorName": "ArithmeticOperator",
|
||||
"original": "-",
|
||||
"replacement": "+",
|
||||
"status": "Killed",
|
||||
"killingTest": "test/calculator.test.js:test subtraction",
|
||||
"description": "Replaced - with +",
|
||||
"static": false
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"location": {
|
||||
"start": {
|
||||
"line": 13,
|
||||
"column": 9
|
||||
},
|
||||
"end": {
|
||||
"line": 13,
|
||||
"column": 10
|
||||
}
|
||||
},
|
||||
"mutatorName": "ArithmeticOperator",
|
||||
"original": "*",
|
||||
"replacement": "/",
|
||||
"status": "Survived",
|
||||
"_comment": "This mutation survived, indicating a gap in the test suite.",
|
||||
"killingTest": null,
|
||||
"description": "Replaced * with /",
|
||||
"static": false
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path": "src/utils.js",
|
||||
"mutations": [
|
||||
{
|
||||
"id": 4,
|
||||
"location": {
|
||||
"start": {
|
||||
"line": 2,
|
||||
"column": 5
|
||||
},
|
||||
"end": {
|
||||
"line": 2,
|
||||
"column": 7
|
||||
}
|
||||
},
|
||||
"mutatorName": "ConditionalExpression",
|
||||
"original": ">=",
|
||||
"replacement": "<",
|
||||
"status": "Killed",
|
||||
"killingTest": "test/utils.test.js:test isPositive",
|
||||
"description": "Replaced >= with <",
|
||||
"static": false
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"location": {
|
||||
"start": {
|
||||
"line": 6,
|
||||
"column": 12
|
||||
},
|
||||
"end": {
|
||||
"line": 6,
|
||||
"column": 14
|
||||
}
|
||||
},
|
||||
"mutatorName": "LogicalOperator",
|
||||
"original": "&&",
|
||||
"replacement": "||",
|
||||
"status": "Killed",
|
||||
"killingTest": "test/utils.test.js:test isValid",
|
||||
"description": "Replaced && with ||",
|
||||
"static": false
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"location": {
|
||||
"start": {
|
||||
"line": 10,
|
||||
"column": 4
|
||||
},
|
||||
"end": {
|
||||
"line": 10,
|
||||
"column": 5
|
||||
}
|
||||
},
|
||||
"mutatorName": "BooleanLiteral",
|
||||
"original": "true",
|
||||
"replacement": "false",
|
||||
"status": "Survived",
|
||||
"killingTest": null,
|
||||
"description": "Replaced true with false",
|
||||
"static": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
154
skills/mutation-test-runner/assets/mutation_report_template.md
Normal file
154
skills/mutation-test-runner/assets/mutation_report_template.md
Normal file
@@ -0,0 +1,154 @@
|
||||
# Mutation Test Report
|
||||
|
||||
**Plugin:** mutation-test-runner
|
||||
|
||||
**Date:** `[Date of Report Generation]`
|
||||
|
||||
**Project:** `[Project Name]`
|
||||
|
||||
**Version:** `[Project Version or Commit Hash]`
|
||||
|
||||
**Report Generated By:** `[Your Name/Team Name]`
|
||||
|
||||
## Executive Summary
|
||||
|
||||
`[Provide a brief overview of the mutation testing results. Highlight key findings, overall mutation score, and any immediate actions required. For example: "This report details the results of mutation testing conducted on the [Project Name] project. The overall mutation score is [Mutation Score], indicating [Level of Test Coverage - e.g., adequate, concerning, poor] test coverage. [Number] mutants survived, requiring further investigation to improve test suite effectiveness."]`
|
||||
|
||||
## Key Metrics
|
||||
|
||||
| Metric | Value | Description |
|
||||
|----------------------|--------------|----------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| **Mutation Score** | `[Mutation Score - e.g., 85%]` | Percentage of mutants killed by the test suite. A higher score indicates better test coverage. |
|
||||
| **Mutants Generated** | `[Number]` | Total number of mutations injected into the codebase. |
|
||||
| **Mutants Killed** | `[Number]` | Number of mutants that were successfully detected by the test suite. |
|
||||
| **Mutants Survived** | `[Number]` | Number of mutants that were *not* detected by the test suite, indicating potential weaknesses in test coverage. |
|
||||
| **Timeout Mutants** | `[Number]` | Number of mutants that caused a timeout during test execution. This may indicate performance issues or infinite loops introduced by the mutant. |
|
||||
| **No Coverage Mutants** | `[Number]` | Number of mutants in code that is not covered by any tests. |
|
||||
| **Runtime Errors** | `[Number]` | Number of mutants that caused runtime errors during test execution. These errors may indicate issues with the codebase itself. |
|
||||
| **Covered Code** | `[Percentage]` | Percentage of code covered by tests. |
|
||||
|
||||
## Detailed Results
|
||||
|
||||
### Surviving Mutants
|
||||
|
||||
`[This section provides a detailed breakdown of each surviving mutant. For each mutant, include the following information. Provide at least 2-3 examples.]`
|
||||
|
||||
**Mutant ID:** `[Unique identifier for the mutant]`
|
||||
|
||||
**File:** `[Path to the file containing the mutant]`
|
||||
|
||||
**Line Number:** `[Line number where the mutation was injected]`
|
||||
|
||||
**Mutation Type:** `[Type of mutation - e.g., Arithmetic Operator Replacement, Conditional Expression Negation]`
|
||||
|
||||
**Original Code:**
|
||||
|
||||
```
|
||||
[Original code snippet]
|
||||
```
|
||||
|
||||
**Mutated Code:**
|
||||
|
||||
```
|
||||
[Mutated code snippet]
|
||||
```
|
||||
|
||||
**Description:** `[A brief explanation of the mutation and its potential impact.]`
|
||||
|
||||
**Reason for Survival:** `[Hypothesized reason why the test suite failed to detect this mutant. For example: "Missing test case for this specific scenario," "Insufficient assertion to catch the changed behavior," "Test only checks for the happy path."]`
|
||||
|
||||
**Recommendations:** `[Specific actions to take to address the surviving mutant. For example: "Add a new test case to cover the edge case," "Strengthen the existing assertion to verify the mutated behavior," "Review the logic in this section of code."]`
|
||||
|
||||
**Example 1:**
|
||||
|
||||
**Mutant ID:** 123
|
||||
|
||||
**File:** `src/calculator.py`
|
||||
|
||||
**Line Number:** 25
|
||||
|
||||
**Mutation Type:** Arithmetic Operator Replacement
|
||||
|
||||
**Original Code:**
|
||||
|
||||
```python
|
||||
def add(x, y):
|
||||
return x + y
|
||||
```
|
||||
|
||||
**Mutated Code:**
|
||||
|
||||
```python
|
||||
def add(x, y):
|
||||
return x - y
|
||||
```
|
||||
|
||||
**Description:** Replaced the addition operator with subtraction.
|
||||
|
||||
**Reason for Survival:** The existing test suite only tested positive numbers and didn't include a test case where the result of the addition would be negative.
|
||||
|
||||
**Recommendations:** Add a test case to `test_calculator.py` that tests the `add` function with inputs that result in a negative sum.
|
||||
|
||||
**Example 2:**
|
||||
|
||||
**Mutant ID:** 456
|
||||
|
||||
**File:** `src/string_utils.py`
|
||||
|
||||
**Line Number:** 10
|
||||
|
||||
**Mutation Type:** Conditional Expression Negation
|
||||
|
||||
**Original Code:**
|
||||
|
||||
```python
|
||||
def is_valid_email(email):
|
||||
if "@" in email:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
```
|
||||
|
||||
**Mutated Code:**
|
||||
|
||||
```python
|
||||
def is_valid_email(email):
|
||||
if "@" not in email:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
```
|
||||
|
||||
**Description:** Negated the conditional expression, effectively inverting the logic of the function.
|
||||
|
||||
**Reason for Survival:** The test suite only checked for valid email addresses but didn't explicitly test for invalid email addresses (those without the "@" symbol).
|
||||
|
||||
**Recommendations:** Add test cases to `test_string_utils.py` that specifically test the `is_valid_email` function with invalid email address formats (e.g., missing "@" symbol, missing domain).
|
||||
|
||||
### Timeout Mutants
|
||||
|
||||
`[If any mutants timed out, provide details about them, including file, line number, and potential causes.]`
|
||||
|
||||
### No Coverage Mutants
|
||||
|
||||
`[List any mutants that were not covered by tests. This indicates dead code or areas where tests are completely missing.]`
|
||||
|
||||
### Runtime Errors
|
||||
|
||||
`[Detail any mutants that caused runtime errors. This might reveal underlying bugs in the code.]`
|
||||
|
||||
## Analysis and Recommendations
|
||||
|
||||
`[Provide a comprehensive analysis of the mutation testing results. Discuss the overall strengths and weaknesses of the test suite. Offer specific recommendations for improving test coverage and addressing the surviving mutants. Include actionable steps and prioritize areas for improvement.]`
|
||||
|
||||
**Example Recommendations:**
|
||||
|
||||
* **Increase Test Coverage:** Focus on adding tests to cover the areas identified by the surviving mutants and no coverage mutants.
|
||||
* **Strengthen Assertions:** Review existing test assertions to ensure they are robust enough to detect subtle changes in behavior.
|
||||
* **Test Edge Cases:** Pay particular attention to testing edge cases and boundary conditions.
|
||||
* **Refactor Code:** In some cases, the surviving mutants may indicate areas of code that are overly complex or difficult to test. Consider refactoring these areas to improve testability.
|
||||
* **Improve Test Data:** Ensure the test data used is diverse and representative of real-world scenarios.
|
||||
|
||||
## Conclusion
|
||||
|
||||
`[Summarize the key findings and recommendations. Reiterate the importance of mutation testing as a tool for improving test suite effectiveness and ensuring code quality. State the next steps for addressing the identified issues.]`
|
||||
Reference in New Issue
Block a user