Skip to content

Commit eb07dfd

Browse files
committed
feat: update examples to use gpt-4o-mini
1 parent 4e868d3 commit eb07dfd

File tree

11 files changed

+191
-312
lines changed

11 files changed

+191
-312
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Check it out here: [Roadmap](https://github.com/codeintegrity-ai/mutahunter/issu
1919

2020
We'd love to hear your feedback, suggestions, and any thoughts you have on mutation testing. Join the discussion and share your insights on the roadmap or any other ideas you have. 🙌
2121

22-
2322
## Table of Contents
2423

2524
- [Features](#features)

examples/go_webservice/README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,34 @@ gocov convert coverage.out | gocov-xml > coverage.xml
1919
Currently test coverage is 96.6%. Let's see what the mutation coverage is.
2020

2121
```bash
22-
# --extreme flag is used to run the mutation testing in extreme mode. This does not use the LLM-based model.
23-
mutahunter run --test-command "go test" --code-coverage-report-path "coverage.xml" --only-mutate-file-paths "app.go" --extreme
24-
25-
# After achieving a high mutation score, let's say 90%, you can check one last time using LLM-based
26-
27-
# go seems to do pretty bad when using gpt-3.5-turbo, so we recommend using gpt-4o
28-
2922
export OPENAI_API_KEY=your-key-goes-here
3023

31-
mutahunter run --test-command "go test" --code-coverage-report-path "coverage.xml" --only-mutate-file-paths "app.go" --model "gpt-4o"
32-
33-
## you can use --modifies-files-only to only mutate the files that are modified by the test suite
34-
mutahunter run --test-command "go test" --code-coverage-report-path "coverage.xml" --only-mutate-file-paths "app.go" --extreme --modifies-files-only
24+
mutahunter run --test-command "go test" --code-coverage-report-path "coverage.xml" --only-mutate-file-paths "app.go" --model "gpt-4o-mini"
25+
```
3526

36-
## and then keeping improving the test suite until you get 100%
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
3747
```
48+
49+
### Surviving Mutant Analysis
50+
51+
[Mutants](./mutants.json)
52+
[Report](./mutant_analysis.md)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
### Vulnerable Code Areas
2+
**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.
5+
6+
### 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+
14+
### Improvement Recommendations
15+
**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.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
### Vulnerable Code Areas
2+
**File:** `src/main/java/com/example/BankAccount.java`
3+
**Location:** Lines 28, 36, 39, 66
4+
**Description:** The methods `deposit` and `withdraw` do not handle zero or negative amounts correctly. Specifically, the `withdraw` method ignores the overdraft limit if the withdrawal amount is less than the balance. Additionally, the `scheduleTransaction` method allows for scheduling transactions with zero days, which could lead to unintended immediate execution.
5+
6+
### Test Case Gaps
7+
**File:** `src/test/java/com/example/BankAccountTest.java`
8+
**Location:** Test methods `testDeposit`, `testWithdraw`, and `testScheduleTransaction`
9+
**Reason:** Existing test cases do not account for edge cases such as zero or negative deposit/withdrawal amounts. The tests also fail to validate the behavior when overdraft limits are ignored or when scheduling transactions for zero days.
10+
11+
### Improvement Recommendations
12+
**New Test Cases Needed:**
13+
1. **Test Method:** `testDepositZeroOrNegativeAmount`
14+
- **Description:** Verify that depositing zero or negative amounts throws an `IllegalArgumentException`.
15+
16+
2. **Test Method:** `testWithdrawZeroOrNegativeAmount`
17+
- **Description:** Ensure that attempting to withdraw zero or negative amounts results in an `IllegalArgumentException`.
18+
19+
3. **Test Method:** `testWithdrawExceedingBalanceIgnoringOverdraft`
20+
- **Description:** Test the scenario where a withdrawal exceeds the balance but is within the overdraft limit to confirm proper handling.
21+
22+
4. **Test Method:** `testScheduleTransactionZeroDays`
23+
- **Description:** Validate that scheduling a transaction for zero days raises an `IllegalArgumentException`.
24+
25+
By addressing these gaps, the test suite will better cover critical edge cases, enhancing the robustness of the `BankAccount` class.

0 commit comments

Comments
 (0)