You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cover_agent/PromptBuilder.py
+16-6Lines changed: 16 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,7 @@ def __init__(
42
42
additional_instructions: str="",
43
43
failed_test_runs: str="",
44
44
language: str="python",
45
+
mutation_testing: bool=False,
45
46
):
46
47
"""
47
48
The `PromptBuilder` class is responsible for building a formatted prompt string by replacing placeholders with the actual content of files read during initialization. It takes in various paths and settings as parameters and provides a method to generate the prompt.
@@ -72,6 +73,7 @@ def __init__(
72
73
self.test_file=self._read_file(test_file_path)
73
74
self.code_coverage_report=code_coverage_report
74
75
self.language=language
76
+
self.mutation_testing=mutation_testing
75
77
# add line numbers to each line in 'source_file'. start from 1
You are an AI mutation testing agent tasked with mutating {{ language }} code to evaluate its robustness.
8
+
9
+
Mutation Strategy:
10
+
11
+
1. Logic Tweaks:
12
+
Modify conditions (e.g., 'if (a < b)' to 'if (a <= b)')
13
+
Adjust loop boundaries
14
+
Introduce minor calculation errors
15
+
Avoid drastic changes or infinite loops.
16
+
17
+
2. Output Modifications:
18
+
Change return types or formats
19
+
Alter response structures
20
+
Return corrupted or incorrect data
21
+
22
+
3. Method Interference:
23
+
Alter function parameters
24
+
Replace or omit key method calls
25
+
26
+
4. Failure Injection:
27
+
Introduce exceptions or error states
28
+
Simulate system or resource failures
29
+
30
+
5.Data Handling Faults:
31
+
Inject parsing errors
32
+
Bypass data validation
33
+
Corrupt object states
34
+
35
+
6. Boundary Condition Testing:
36
+
Use out-of-bounds indices
37
+
Test extreme or edge-case parameters
38
+
39
+
7. Concurrency Issues:
40
+
Simulate race conditions or deadlocks
41
+
Introduce timeouts or delays
42
+
43
+
8. Security Vulnerabilities:
44
+
Replicate common vulnerabilities (e.g., buffer overflow, SQL injection, XSS)
45
+
Introduce authentication or authorization bypasses
46
+
47
+
48
+
Focus on subtle, realistic mutations that challenge the code's resilience while keeping core functionality intact. Prioritize scenarios likely to arise from programming errors or edge cases.
49
+
50
+
51
+
## Source Code to add Mutations to: {{ source_file_name }}
52
+
```{{language}}
53
+
{{ source_file_numbered }}
54
+
```
55
+
56
+
## Task
57
+
1. Conduct a line-by-line analysis of the source code.
58
+
2. Generate mutations for each test case.
59
+
3. Prioritize mutating function blocks and critical code sections.
60
+
4. Ensure the mutations offer meaningful insights into code quality and test coverage.
61
+
5. Present the output in order of ascending line numbers.
62
+
6. Avoid including manually inserted line numbers in the response.
63
+
7. Limit mutations to single-line changes only.
64
+
65
+
Example output:
66
+
```yaml
67
+
file: {{source_file}}
68
+
mutations:
69
+
- method: <function name>
70
+
category: <mutation type>
71
+
summary: <brief mutation description>
72
+
location: <line number>
73
+
original: |
74
+
<original code>
75
+
mutated_version: |
76
+
<mutated code with {{language}} comment explaining the change>
77
+
```
78
+
79
+
Use block scalar('|') to format each YAML output.
80
+
81
+
Response (should be a valid YAML, and nothing else):
82
+
```yaml
83
+
84
+
Generate mutants that test the code’s resilience while preserving core functionality. Output only in YAML format, with no additional explanations or comments.
0 commit comments