2 |
3 |
Mutahunter
4 |
5 |
Open-Source Language Agnostic LLM-based Mutation Testing
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | ## Getting Started with Mutation Testing
15 |
16 | ```bash
17 | # Install Mutahunter package via GitHub. Python 3.11+ is required.
18 | $ pip install https://github.com/codeintegrity-ai/mutahunter
19 |
20 | # Work with GPT-4o on your repo
21 | $ export OPENAI_API_KEY=your-key-goes-here
22 |
23 | # Run Mutahunter on a specific file.
24 | $ mutahunter run --test-command "mvn clean test" --model "gpt-4o-mini" --source-path "src/main/java/com/example/BankAccount.java" --test-path "src/test/java/BankAccountTest.java"
25 |
26 |
27 | 2025-03-05 18:56:42,528 INFO: 'mvn clean test' - '/Users/taikorind/Desktop/mutahunter/examples/java_maven/logs/_latest/mutants/34a5d8a5_BankAccount.java'
28 | 2025-03-05 18:56:44,935 INFO: 🛡️ Mutant survived 🛡️
29 |
30 | 2025-03-05 18:56:44,936 INFO: 'mvn clean test' - '/Users/taikorind/Desktop/mutahunter/examples/java_maven/logs/_latest/mutants/183e6826_BankAccount.java'
31 | 2025-03-05 18:56:47,308 INFO: 🗡️ Mutant killed 🗡️
32 |
33 | . . . .-. .-. . . . . . . .-. .-. .-.
34 | |\/| | | | |-| |-| | | |\| | |-| |
35 | ' ` `-' ' ` ` ' ' ` `-' ' ` `-' ' '
36 |
37 | 2024-07-29 12:31:22,045 INFO:
38 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
39 |
40 | 📊 Overall Mutation Coverage 📊
41 | 🎯 Mutation Coverage: 57.14% 🎯
42 | 🦠 Total Mutants: 7 🦠
43 | 🛡️ Survived Mutants: 3 🛡️
44 | 🗡️ Killed Mutants: 4 🗡️
45 | 🕒 Timeout Mutants: 0 🕒
46 | 🔥 Compile Error Mutants: 1 🔥
47 | 💰 Total Cost: $0.00060 USD 💰
48 |
49 | =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
50 | 2025-03-05 18:56:54,689 INFO: Mutation Testing Ended. Took 29s
51 | ```
52 |
53 | ### Examples
54 |
55 | Go to the examples directory to see how to run Mutahunter on different programming languages:
56 |
57 | Check [Java Example](/examples/java_maven/) to see some interesting LLM-based mutation testing examples.
58 |
59 | - [Java Example](/examples/java_maven/)
60 |
61 |
62 |
--------------------------------------------------------------------------------
/examples/java_maven/src/main/java/com/example/BankAccount.java:
--------------------------------------------------------------------------------
1 | package com.example;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | public class BankAccount {
7 |
8 | private double balance;
9 | private double overdraftLimit;
10 | private List