Skip to content

Commit 54bb883

Browse files
authored
Improved prompt and reduce token cost
* chore: update examples * feat: modify default model to gpt-4o-model * feat: modify json to yaml reducing token cost and improve prompt * chore: version bump to 1.1.4
1 parent 737c18c commit 54bb883

File tree

21 files changed

+554
-852
lines changed

21 files changed

+554
-852
lines changed

examples/go_webservice/README.md

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,28 +24,6 @@ export OPENAI_API_KEY=your-key-goes-here
2424
mutahunter run --test-command "go test" --code-coverage-report-path "coverage.xml" --only-mutate-file-paths "app.go" --model "gpt-4o-mini"
2525
```
2626

27-
```bash
28-
2024-07-18 16:13:56,632 INFO: 📊 Overall Mutation Coverage 📊
29-
📈 Line Coverage: 97.00% 📈
30-
🎯 Mutation Coverage: 52.63% 🎯
31-
🦠 Total Mutants: 21 🦠
32-
🛡️ Survived Mutants: 9 🛡️
33-
🗡️ Killed Mutants: 10 🗡️
34-
🕒 Timeout Mutants: 0 🕒
35-
🔥 Compile Error Mutants: 2 🔥
36-
💰 Expected Cost: $0.00579 USD 💰
37-
2024-07-18 16:13:56,632 INFO: 📂 Detailed Mutation Coverage 📂
38-
📂 Source File: app.go 📂
39-
🎯 Mutation Coverage: 52.63% 🎯
40-
🦠 Total Mutants: 21 🦠
41-
🛡️ Survived Mutants: 9 🛡️
42-
🗡️ Killed Mutants: 10 🗡️
43-
🕒 Timeout Mutants: 0 🕒
44-
🔥 Compile Error Mutants: 2 🔥
45-
46-
2024-07-18 16:13:59,928 INFO: Mutation Testing Ended. Took 121s
47-
```
48-
4927
### Surviving Mutant Analysis
5028

5129
[Mutants](./mutants.json)
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
11
### Vulnerable Code Areas
22
**File:** `app.go`
3-
**Location:** Multiple functions including `subtractHandler`, `multiplyHandler`, `isPalindromeHandler`, `daysUntilNewYearHandler`, and `echoHandler`.
4-
**Description:** The surviving mutants indicate that the code lacks robust error handling for parameter conversions and edge cases, such as empty inputs and boundary conditions. For instance, the `subtractHandler` does not handle conversion errors, and the `multiplyHandler` incorrectly returns 0 when either number is 0 without proper context.
3+
**Location:** Multiple functions
4+
**Description:** The following areas are vulnerable due to surviving mutants:
5+
1. **`welcomeHandler`**: The response key was altered from "message" to "msg", indicating a lack of strict key validation in tests.
6+
2. **`currentDateHandler`**: The response structure was changed to omit the "date" key, highlighting insufficient checks on response formats.
7+
3. **`divideHandler`**: The condition for division by zero was modified to allow division by zero, which could lead to runtime errors.
8+
4. **`sqrtHandler`**: The condition for negative numbers was weakened, allowing invalid inputs.
9+
5. **`daysUntilNewYearHandler`**: An off-by-one error was introduced, indicating a lack of thorough validation in date calculations.
10+
6. **`reverse`**: The loop condition was altered to create an infinite loop, showcasing potential flaws in logic handling.
511

612
### Test Case Gaps
7-
**File:** `app_test.go` (assumed)
8-
**Location:** Various test methods for arithmetic operations and string manipulations.
9-
**Reason:** Existing test cases likely do not cover scenarios such as:
10-
- Invalid or empty parameters (e.g., `subtractHandler` and `echoHandler`).
11-
- Edge cases like multiplying by zero or checking for palindromes with empty strings.
12-
- Leap year considerations in `daysUntilNewYearHandler`.
13+
**File:** `app_test.go`
14+
**Location:** Various test methods
15+
**Reason:** Existing tests likely do not cover:
16+
1. Response structure validation, leading to undetected key changes.
17+
2. Edge cases for division and square root operations, such as zero and negative inputs.
18+
3. Logical errors in date calculations, which require comprehensive boundary testing.
19+
4. Infinite loop scenarios that could arise from incorrect loop conditions.
1320

1421
### Improvement Recommendations
1522
**New Test Cases Needed:**
16-
1. **Test Method:** `testSubtractHandlerInvalidInput`
17-
- **Description:** Validate behavior when non-integer inputs are provided.
18-
2. **Test Method:** `testMultiplyHandlerZeroInput`
19-
- **Description:** Ensure that multiplication by zero is handled correctly and returns a meaningful response.
20-
3. **Test Method:** `testIsPalindromeHandlerEmptyString`
21-
- **Description:** Check the response when an empty string is passed to the palindrome check.
22-
4. **Test Method:** `testDaysUntilNewYearHandlerLeapYear`
23-
- **Description:** Test the calculation of days until New Year during a leap year to ensure accuracy.
24-
5. **Test Method:** `testEchoHandlerEmptyMessage`
25-
- **Description:** Validate the response when an empty message is provided, ensuring proper error handling.
26-
27-
By addressing these gaps, the robustness of the application can be significantly improved, ensuring better handling of edge cases and invalid inputs.
23+
1. **Test Method:** `testWelcomeHandlerResponseStructure`
24+
- **Description:** Validate that the response contains the correct key ("message") and value.
25+
2. **Test Method:** `testCurrentDateHandlerResponse`
26+
- **Description:** Ensure the response includes the "date" key with a valid date format.
27+
3. **Test Method:** `testDivideByZero`
28+
- **Description:** Test division by zero to confirm proper error handling.
29+
4. **Test Method:** `testSqrtNegativeInput`
30+
- **Description:** Check the response when a negative number is passed to the square root function.
31+
5. **Test Method:** `testDaysUntilNewYearCalculation`
32+
- **Description:** Validate the calculation of days until New Year, ensuring no off-by-one errors.
33+
6. **Test Method:** `testReverseFunctionInfiniteLoop`
34+
- **Description:** Test the reverse function with various inputs to ensure it does not enter an infinite loop.

0 commit comments

Comments
 (0)