Files
gh-jeremylongshore-claude-c…/skills/mutation-test-runner/assets/mutation_report_template.md
2025-11-30 08:23:18 +08:00

6.7 KiB

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:

def add(x, y):
  return x + y

Mutated Code:

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:

def is_valid_email(email):
  if "@" in email:
    return True
  else:
    return False

Mutated Code:

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.]